forked from tsgates/die
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
86 lines (66 loc) · 2.63 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
MAIN ?= p
DIFF ?= HEAD^
CODE := $(addsuffix .tex,$(filter-out %.tex,$(wildcard code/*)))
FIGS := $(patsubst %.svg,%.pdf,$(wildcard fig/*.svg))
ODGS := $(patsubst %.odg,%.pdf,$(wildcard fig/*.odg))
PLOT := $(patsubst %.gp,%.tex,$(wildcard data/*.gp))
DEPS := rev.tex code/fmt.tex abstract.txt $(CODE) $(FIGS) $(ODGS) $(PLOT)
LTEX := --latex-args="-synctex=1 -shell-escape"
BTEX := --bibtex-args="-min-crossrefs=99"
SHELL:= $(shell echo $$SHELL)
all: $(DEPS) ## generate a pdf
@TEXINPUTS="sty:" bin/latexrun $(LTEX) $(BTEX) $(MAIN)
cp latex.out/$(MAIN).synctex.gz .
submit: $(DEPS) ## proposal function
@for f in $(wildcard submit-*.tex); do \
TEXINPUTS="sty:" bin/latexrun $$f; \
done
diff: $(DEPS) ## generate diff-highlighed pdf
@bin/diff.sh $(DIFF)
help: ## print help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}'
rev.tex: FORCE
@printf '\\gdef\\therev{%s}\n\\gdef\\thedate{%s}\n' \
"$(shell git rev-parse --short HEAD)" \
"$(shell git log -1 --format='%ci' HEAD)" > $@
code/%.tex: code/% ## build highlighted tex code from source code
pygmentize -P tabsize=4 -P mathescape -f latex $^ | bin/mark.py > $@
code/fmt.tex: ## generate color table
pygmentize -f latex -S default > $@
fig/%.pdf: fig/%.svg ## generate pdf from svg
bin/svg2pdf.sh ${CURDIR}/$^ ${CURDIR}/$@
fig/%.pdf: fig/%.odg ## generate pdf from LibreOffice Draw
bin/odg2pdf.sh $^ $@
data/%.tex: data/%.gp ## generate plot
gnuplot $^
data/%.pdf: data/%.py ## generate plot
python3 $^
draft: $(DEPS) ## generate pdf with a draft info
echo -e '\\newcommand*{\\DRAFT}{}' >> rev.tex
@TEXINPUTS="sty:" bin/latexrun $(BTEX) $(MAIN)
watermark: $(DEPS) ## generate pdf with a watermark
echo -e '\\usepackage[firstpage]{draftwatermark}' >> rev.tex
@TEXINPUTS="sty:" bin/latexrun $(BTEX) $(MAIN)
spell: ## run a spell check
@for i in *.tex fig/*.tex; do bin/aspell.sh tex $$i; done
@for i in *.tex; do bin/double.pl $$i; done
@for i in *.tex; do bin/abbrv.pl $$i; done
@bin/hyphens.sh *.tex
@pdftotext $(MAIN).pdf /dev/stdout | grep '??'
@for i in fig/*.svg; do bin/aspell.sh svg $$i; done
@for i in code/*.c; do bin/aspell.sh code $$i; done
bib: all ## print bib used in the paper
bibexport latex.out/$(MAIN).aux
clean: ## clean up
@bin/latexrun --clean
rm -f abstract.txt
rm -f $(MAIN).synctex.gz
distclean: clean ## clean up completely
rm -f code/*.tex
rm -rf _minted_p
abstract.txt: abstract.tex $(MAIN).tex ## generate abstract.txt
@bin/mkabstract $(MAIN).tex $< | fmt -w72 > $@
text:
@bin/mktext p.tex
.PHONY: all help FORCE draft clean spell distclean init bib