forked from m4dc4p/cheatsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·45 lines (35 loc) · 988 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
45
#@IgnoreInspection BashAddShebang
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 := /root/.cabal/bin/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))