-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
56 lines (40 loc) · 1.35 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
BUILDDIR=build
LATEXMK=latexmk
INKSCAPE=inkscape
FIGDIR=assets/figures
DRAWIO=drawio
OUT=report
SVGS=$(wildcard $(FIGDIR)/*.svg)
DIOS=$(wildcard $(FIGDIR)/*.drawio)
PDFS=$(wildcard $(FIGDIR)/*.pdf)
PYFS=$(wildcard $(FIGDIR)/*.py)
FIGS_SVG=$(patsubst %.svg, $(BUILDDIR)/%.svg.pdf, $(SVGS))
FIGS_DIO=$(patsubst %.drawio, $(BUILDDIR)/%.drawio.pdf, $(DIOS))
FIGS_PDF=$(patsubst %.pdf, $(BUILDDIR)/%.pdf, $(PDFS))
FIGS_PY=$(patsubst %.py, $(BUILDDIR)/%.py.pdf, $(PYFS))
FIGS=$(FIGS_SVG) $(FIGS_DIO) $(FIGS_PDF) $(FIGS_PY)
all: $(OUT).tex $(FIGS) | $(BUILDDIR)
$(LATEXMK) -pdf
figures: $(FIGS)
$(FIGS_SVG): $(BUILDDIR)/%.svg.pdf: %.svg | dirs
dbus-run-session inkscape --export-area-drawing -o $@ $<
$(FIGS_PY): $(BUILDDIR)/%.py.pdf: %.py | dirs
python3 $< > $@
$(FIGS_DIO): $(BUILDDIR)/%.drawio.pdf: %.drawio | dirs
xvfb-run -a $(DRAWIO) --crop --export --format pdf --output $@ $< --disable-gpu --headless --no-sandbox
$(FIGS_PDF): $(BUILDDIR)/%.pdf: %.pdf | dirs
cp $< $@
dirs: $(BUILDDIR)
$(BUILDDIR): $(BUILDDIR)/$(FIGDIR)
$(BUILDDIR)/$(FIGDIR):
mkdir -p $@
clean:
$(RM) $(BUILDDIR)/$(OUT).*
$(LATEXMK) -C
mrproper:
$(RM) -rf $(BUILDDIR)
biber: bibliography.bib
biber --tool --validate-datamodel $<
fresh: $(wildcard *.tex)
find . -name '*.tex' -print0 | xargs -n1 -0 perl -0777 -pi -e "s/\%\%if.+?\%\%fi//gs"
.PHONY: all figures dirs clean mrproper biber fresh