-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
44 lines (34 loc) · 933 Bytes
/
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: CheatSheet.dvi
all: CheatSheet.pdf
# The output of lhs2TeX
cleansuffix += .tex
# Various temporary files from LaTeX
cleansuffix += .aux .log .out .ptb
# The final output
cleansuffix += .dvi .ps .pdf
latexflags := -interaction=nonstopmode -file-line-error-style
latex := latex $(latexflags)
pdflatex := pdflatex $(latexflags)
lhs2TeX := lhs2TeX --verb
dvips := dvips
define run-while-needed
@while true; do \
printf '%s\n' '$(1) "$<"'; \
$(1) "$<" >/dev/null; \
if ! egrep -q 'Warning:.*Rerun' "$(<:.tex=.log)"; then break; fi; \
done; \
egrep '\.tex:|Warning|Error|XXX|TODO|FIXME' "$(<:.tex=.log)" >&2 || true; \
! egrep -q Error "$(<:.tex=.log)"
endef
.NOTPARALLEL:
%.tex: %.lhs
$(lhs2TeX) "$<" >"$@"
%.dvi: %.tex
$(call run-while-needed,$(latex))
%.ps: %.dvi
$(dvips) "$<"
%.pdf: %.tex
$(call run-while-needed,$(pdflatex))
.PHONY: clean
clean:
$(RM) $(addprefix CheatSheet,$(cleansuffix))