-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (48 loc) · 1.99 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Latex Makefile using latexmk
# Modified by Dogukan Cagatay <[email protected]>
# Modified by Philipp Jund
# Modified by Felix Karg <[email protected]>
# Adapted from : http://tex.stackexchange.com/a/40759
# Additional Source:
# https://serverfault.com/questions/153875/how-to-let-cp-command-dont-fire-an-error-when-source-file-does-not-exist
PROJNAME=main_handout main_present
PDFNAMES=$(addsuffix .pdf, $(PROJNAME))
COMPRESSED=$(addsuffix .compressed.pdf, $(PROJNAME))
OUT_DIR=out
.PHONY: fast all watch compress clean dist-clean
fast: main_handout.pdf main_handout.pdfpc
all: $(PDFNAMES) $(addsuffix .pdfpc, $(PROJNAME))
compress: $(COMPRESSED)
# '.' prevents of having to specify the complete filename (as we may be copying multiple files)
# '||' is similar to a pipe, but only run if an error happened
# ':' is a posix-'true', preventing it from failing if a file was missing (allowing 'make fast')
# %.pdf: %.tex *.tex */*.tex references.bib img/*
%.pdf: %.tex *.tex */*.tex references.bib img/* code/*
mkdir -p $(OUT_DIR)/$*/chapters/
latexmk -outdir=$(OUT_DIR)/$* -pdf -use-make -file-line-error -shell-escape $< || :
# lualatex --file-line-error --output-directory=$(OUT_DIR)/$* --interaction=nonstopmode $< || :
cp -v $(OUT_DIR)/$*/$*.pdf . || :
# the sed commands transform:
# - newlines (\\) into actual newlines
# - (\par) in two newlines
# - trim whitespaces
%.pdfpc: %.pdf
cp -v $(OUT_DIR)/$*/$*.pdfpc . || :
sed -i 's/\\\\/\n/g' $*.pdfpc
sed -i 's/\\par/\n\n/g' $*.pdfpc
sed -i "s/^[ \t]*//;s/[ \t]*$$//" $*.pdfpc
watch:
latexmk -pvc -outdir=$(OUT_DIR)/$* -pdf -use-make -file-line-error -shell-escape $(PROJNAME).tex
# -dPDFSETTINGS=
# Filesize: /ebook < /printer < /prepress < /default
%.compressed.pdf: %.pdf
gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dPrinted=false -dBATCH -dPDFSETTINGS=/default -sOutputFile=$@ $<
cp $@ $<
dist-clean: clean
rm -rf $(PDFNAMES)
rm -rf $(COMPRESSED)
rm -rf $(addsuffix .pdfpc, $(PROJNAME))
rm -rf _minted-*
clean:
rm -rf $(OUT_DIR)
rm -rf *.out *.log *.aux