-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (51 loc) · 2.92 KB
/
Makefile
File metadata and controls
67 lines (51 loc) · 2.92 KB
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
DOC_COMPILER := lualatex -interaction=batchmode
FIGURE_COMPILER := pdflatex -interaction=batchmode
FIGURES_TEX_PDF := $(patsubst figures/%.tex,output/%.pdf,$(wildcard figures/*.tex))
FIGURES_ASY_PDF := $(patsubst figures/%.asy,output/%.pdf,$(wildcard figures/*.asy))
FIGURES_PY_PDF := $(patsubst src/notebook/figures/%.py,output/%.pdf,$(filter-out src/notebook/figures/__init__.py, $(wildcard src/notebook/figures/*.py)))
PYTHON_SOURCE := $(wildcard src/*.py)
TEXT_SOURCE := notebook.tex classes/notebook.cls bibliography/*.bib asymptote/*.asy asymptote/geom/*.asy asymptote/graphs/*.asy asymptote/square_grid_automaton/*.asy packages/*.sty text/*.tex aux/corderef.aux $(FIGURES_TEX_PDF) $(FIGURES_ASY_PDF) $(FIGURES_PY_PDF)
.PHONY: figures clean clean-text clean-figures touch-figures checkcites
.DEFAULT_GOAL := output/notebook.pdf
aux:
mkdir --parents aux
aux/text:
mkdir --parents aux/text
output:
mkdir --parents output
# LaTeX compilation is complicated, so we avoid using Make for intermediate files in aux/
# In the end, we use dd to copy the result (cp messes up reloading of PDF files in viewers)
output/notebook.pdf: $(TEXT_SOURCE) images/*.png $(wildcard includeonly metadata) | aux aux/text output
$(DOC_COMPILER) -output-directory=aux -draftmode notebook.tex
biber --quiet aux/notebook.bcf
$(DOC_COMPILER) -output-directory=aux -draftmode notebook.tex
$(DOC_COMPILER) -output-directory=aux notebook.tex
dd status=none if=aux/notebook.pdf of=output/notebook.pdf
output/%.pdf: figures/%.tex classes/*.cls packages/*.sty | aux output
$(FIGURE_COMPILER) -output-directory=aux figures/$*.tex
dd status=none if=aux/$*.pdf of=output/$*.pdf
# Asymptote may fail silently, so we remove the aux file prior to making a new one
output/%.pdf: figures/%.asy asymptote/*.asy asymptote/geom/*.asy asymptote/graphs/*.asy asymptote/square_grid_automaton/*.asy | aux output
rm --force aux/$*.pdf
asy -outname=aux/$* figures/$*.asy
dd status=none if=aux/$*.pdf of=output/$*.pdf
output/%.pdf: src/notebook/figures/%.py | aux output
uv run python -m src.notebook.figures.$*
dd status=none if=aux/$*.pdf of=output/$*.pdf
figures: $(FIGURES_TEX_PDF) $(FIGURES_ASY_PDF) $(FIGURES_PY_PDF)
# This is occasionally useful in those cases when some TeX/asymptote module is updated,
# but the update does not require rebuilding all figures
touch-figures:
touch $(FIGURES_TEX_PDF)
aux/metadata: .git/refs/heads/master | aux
LC_ALL=en_US.UTF-8 git log --max-count 1 --format=format:'commit={%h},date={%cd}' --date='format:%d %B %Y' HEAD > aux/metadata
LC_ALL=en_US.UTF-8 git log --max-count 1 --format=format:',pdfdate={%cd}' --date='format:D:%Y%m%d%H%M%S' HEAD >> aux/metadata
aux/corderef.aux: $(PYTHON_SOURCE) | aux
uv run coderefs collect
clean-text:
rm --recursive --force aux/text aux/notebook.* output/notebook.pdf
clean-figures:
rm --recursive --force aux output
clean: clean-text clean-figures
checkcites:
checkcites --backend biber --crossrefs --all aux/notebook.bcf