forked from tpo/betriebssysteme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
33 lines (24 loc) · 1.46 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Used docu:
# - http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
# - http://stackoverflow.com/questions/4971865/patsubst-on-makefile
# - http://blog.softwaresafety.net/2010/09/transforming-files-with-wildcards-in.html
# - http://stackoverflow.com/questions/1435861/computing-makefile-variable-on-assignment
#
TMP := $(shell mktemp -d /tmp/MAS_LibreOffice_to_PDF.XXXXXX)
#ODP_FILES := $(wildcard *.odp) # will include symlinks, which we don't want
ODP_FILES := $(shell find . -maxdepth 1 -name "*.odp" -type f -printf "%f\n")
RST_FILES := $(shell find . -maxdepth 1 -name "*.rst" -type f -printf "%f\n")
SYM_FILES := $(shell find . -maxdepth 1 \( -name "*.rst" -o -name "*.odp" \) -type l -printf "%f\n")
OPDF_FILES := $(patsubst %.odp,PDF/%.pdf,$(ODP_FILES))
RPDF_FILES := $(patsubst %.rst,PDF/%.pdf,$(RST_FILES))
SPDF_FILES := $(patsubst %.rst,PDF/%.pdf,$(patsubst %.odp,PDF/%.pdf,$(SYM_FILES)))
PDF/%.pdf: %.odp
libreoffice -env:UserInstallation=file://$(TMP) --headless --invisible --convert-to pdf --outdir PDF "$<"
PDF/%.pdf: %.rst
rst2pdf --header "T.Pospíšek, MAS: Betriebssysteme, ###Title###" --footer "###Page###/###Total###" "$<" -o "$@"
# echo $(for i in $(SYM_FILES); do $(basename $i)
.PHONY: all symlinks
all: $(OPDF_FILES) $(RPDF_FILES) symlinks
symlinks:
cd PDF && [ -h 03-1_Shell.pdf ] || ln -s 02-1_Shell.pdf 03-1_Shell.pdf
cd PDF && [ -h 03-2_Architekturansätze.pdf ] || ln -s 02-2_Architekturansätze.pdf 03-2_Architekturansätze.pdf