-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
122 lines (97 loc) · 3.66 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# USER INPUTS
# =============================================================================
# NAME should match the main .tex file in tex/.
NAME = reproducible
# File extensions for data and figure generation.
FIGEXT = pgf
DATAEXT = feather
# List of figures and generated LaTeX files to make.
figs = \
figures/sine_taylor.$(FIGEXT) \
figures/quadratic_roots.$(FIGEXT) \
texs = \
tex/quadratic_gen.tex \
tex/sine_taylor_gen.tex \
# The convenient names for top-level targets. Must go before the user recipes
# so plain `make` builds whole paper.
full: build/$(NAME).pdf
abridged: abridged_build/$(NAME).pdf
arxiv: build/arxiv.zip
# User recipes for intermediate processing steps where data files are used to
# make more data files.
data/sine_taylor.$(DATAEXT): src/sine_taylor_data.py data/sine_derivs.feather
python src/sine_taylor_data.py data/sine_derivs.feather $@
# =============================================================================
# END OF USER INPUTS
#
# Main pdf builds.
#
LATEXMK = latexmk -pdf -cd -interaction=nonstopmode
TEXDEPS = tex/*.tex tex/*.bib $(texs) $(figs)
# Unabridged (extended) paper.
build/$(NAME).pdf build/$(NAME).bbl: $(TEXDEPS)
$(LATEXMK) -jobname=build/$(NAME) tex/$(NAME).tex
# Abridged paper.
abridged_build/$(NAME).pdf abridged_build/$(NAME).bbl: $(TEXDEPS)
ABRIDGED=true $(LATEXMK) -jobname=abridged_build/$(NAME) tex/$(NAME).tex
#
# Source .zip for arXiv.
#
# Strip comments and unused bibliography from LaTeX source code for arXiv.
build/arxiv: build/$(NAME).pdf build/$(NAME).bbl
rm -rf build/arxiv
arxiv_latex_cleaner tex
mv tex_arXiv build/arxiv
cp -r figures build/arxiv/figures
cp build/$(NAME).bbl build/arxiv
# Zipping the arXiv source for upload.
build/arxiv.zip: build/arxiv
rm -f build/arxiv.zip
cd build/arxiv; zip -r ../arxiv.zip .
#
# Main pattern rules.
#
# Rule to make figures from data files. Figure-generating scripts should take
# the input data path and output image path as the two command-line args.
# If the figure generation does not require any input data, the path to a
# nonexistent file will be passed anyway, and should be ignored.
#
figures/%.$(FIGEXT): data/%.$(DATAEXT) src/%_fig.py
python src/$*_fig.py $< $@
# Rule to make LaTeX from data files. LaTeX-generating scripts should take
# the input data path as the one command-line arg and print to stdout.
# If the LaTeX generation does not require any input data, the path to a
# nonexistent file will be passed anyway, and should be ignored.
#
tex/%_gen.tex: data/%.$(DATAEXT) src/%_gentex.py
python src/$*_gentex.py $< > $@
# Rule to make data files "from scratch" if they do not already exist.
# Data-generating scripts should take output path as the one command-line arg.
#
data/%.$(DATAEXT): src/%_data.py
python src/$*_data.py $@
# For {figure, LaTeX}-generating scripts, the recipe will always look for the
# corresponding *_data file. There are three valid cases to consider:
#
# 1) The script src/%_data.py exists, so `make` can generate the data file
# (see rule above).
# 2) The data file has been generated by the user before ever running `make`,
# and should be copied from input/.
# 3) Neither the input/ file nor src/%_data.py exist, but the
# {figure, LaTeX}-generating script does not actually need the file.
#
# Case 1) is handled by the previous rule. This rule implements the check for
# 2) and the fallback to 3) if 2) does not apply.
#
data/%.$(DATAEXT):
cp input/$*.$(DATAEXT) $@ 2>/dev/null || true
# Do not delete data files when done building downstream dependencies,
# even though they are "intermediate files".
#
.PRECIOUS: data/%.$(DATAEXT)
clean:
rm -f $(texs)
rm -f $(figs)
rm -rf data/*
rm -rf build/*
rm -rf abridged_build/*