summaryrefslogtreecommitdiff
path: root/Makefile
blob: 1266971f0095e229b2a57444cfcca548cf16067b (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 TMP := $(shell mktemp -d --suffix=$(TEMPSUFFIX)))
	@cp -r * $(TMP)/
	cd $(TMP)/; \
		$(TEX2PDF) $(TEXFLAGS) $<;
	@cp $(TMP)/$@ $@
	@$(RM) -r $(TMP)

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

watch: watch.sh
	./watch.sh

.PHONY: all clean watch