phd-thesis/Makefile
2026-01-20 07:48:08 +01:00

62 lines
2.4 KiB
Makefile

SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
CHAPTERS := $(shell find -maxdepth 1 -type d -name 'chapter-*')
VERSION_STRING := $(shell git describe --always --tags --long)
all: thesis.pdf
# We need three runs for biblatex's defernumbers
%.pdf: %.tex common-packages.tex common-defs.tex main.bib version.tex
pdflatex -shell-escape -jobname $* '\def\thesispreviewmode{}\input{$<}'
biber $*
pdflatex -shell-escape -jobname $* '\def\thesispreviewmode{}\input{$<}'
pdflatex -shell-escape -jobname $* '\def\thesispreviewmode{}\input{$<}'
echo
echo "Undefined biblatex references:"
grep -A2 'Package biblatex Warning: The following entry could not be found' thesis.log | sed -n '3~4{s/(biblatex) *//;p}' || echo "<None>"
%-oneside.pdf: %.tex common-packages.tex common-defs.tex main.bib version.tex
pdflatex -shell-escape -jobname $*-oneside '\def\thesispreviewmode{}\def\thesisoneside{}\input{$<}'
biber $*-oneside
pdflatex -shell-escape -jobname $*-oneside '\def\thesispreviewmode{}\def\thesisoneside{}\input{$<}'
pdflatex -shell-escape -jobname $*-oneside '\def\thesispreviewmode{}\def\thesisoneside{}\input{$<}'
echo
echo "Undefined biblatex references:"
grep -A2 'Package biblatex Warning: The following entry could not be found' thesis.log | sed -n '3~4{s/(biblatex) *//;p}' || echo "<None>"
%-final.pdf: %.tex common-packages.tex common-defs.tex main.bib version.tex abstract.tex abstract-de.tex
pdflatex -jobname $*-final -shell-escape $<
biber $*-final
pdflatex -jobname $*-final -shell-escape $<
pdflatex -jobname $*-final -shell-escape $<
%-final-oneside.pdf: %.tex common-packages.tex common-defs.tex main.bib version.tex
pdflatex -shell-escape -jobname $*-final-oneside '\def\thesisoneside{}\input{$<}'
biber $*-final-oneside
pdflatex -shell-escape -jobname $*-final-oneside '\def\thesisoneside{}\input{$<}'
pdflatex -shell-escape -jobname $*-final-oneside '\def\thesisoneside{}\input{$<}'
version.tex: thesis.tex $(addsuffix /chapter.tex,${CHAPTERS})
echo "${VERSION_STRING}" > $@
.PHONY: update-figures
update-figures:
@for ch in ${CHAPTERS};\
do \
test -d $$ch/figures &&\
python update_figures.py $$ch/figures || true;\
done
.PHONY: clean
clean:
rm -f **.aux **.bbl **.bcf **.log **.blg **.lof **.lot
rm -f **.mtc **.mtc* **.maf **.toc
rm -f **.out **.run.xml **/texput.log