summaryrefslogtreecommitdiff
path: root/Makefile
blob: c8978ef1d422fa97d192485a0341a2a4361b7b64 (plain)
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
TEX := $(wildcard *.tex)
NAMES := $(TEX:.tex=.pdf)
TEX2PDF := xelatex
TEXFLAGS :=
TEMPSUFFIX := tex

# Target that matches all possible generated PDFs
all: $(NAMES)
$(NAMES): $(%:.pdf=.tex)

# Rule that builds the tex file in a temp directory and copies it
%.pdf: %.tex
	$(eval TEMP := $(shell mktemp -d --suffix=$(TEMPSUFFIX)))
	@cp -r * $(TEMP)/
	cd $(TEMP)/; \
		$(TEX2PDF) $(TEXFLAGS) $<;
	@cp $(TEMP)/$@ $@
	@$(RM) -r $(TEMP)

# Rule that cleans all previous content
clean:
	@$(RM) *.pdf
	@$(RM) -r /tmp/*$(TEMPSUFFIX)

watch: watch.sh
	./watch.sh

.PHONY: all clean watch