-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (35 loc) · 1.28 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
all: out/git-gud.pdf images
.PHONY: images all
# Recursive wildcard from https://stackoverflow.com/a/18258352
#
# To find every .c file in src:
# FILES := $(call rwildcard, ,src/ *.c)
# To find all the .c and .h files in src:
# FILES := $(call rwildcard, src/, *.c *.h)
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
DEPS := $(call rwildcard, slides/, *.tex)
DEPS := $(DEPS) $(call rwildcard, imgs/, *.png)
# Regenerate the slides if any file changes
#
# Since pdflatex creates the output from the main input file
# (e.g., main.tex -> main.pdf), replace .pdf suffix in the output
# by .tex in the input, also renaming the input directory.
#
# As dumb as this seems, the toc only appears if pdflatex
# is run twice, and (afaik) there's no way to rename the file generated
# by pdflatex...
out/git-gud.pdf: slides/main.tex $(DEPS) | out/.mkdir
pdflatex -halt-on-error -output-directory=out $<
pdflatex -halt-on-error -output-directory=out $<
mv $(<:slides/%.tex=out/%.pdf) $@
images: out/img/.timestamp
out/img/.timestamp: out/git-gud.pdf | out/img/.mkdir
convert -density 204 $< $(@D)/img.png
@ touch out/img/.timestamp
@ echo "Images generated at $(@D)"
# Automatically creates a directory.
%.mkdir:
mkdir -p $(@D)
touch $@
clean:
rm -rf out/