all: build/loesung.pdf

build/loesung.pdf: FORCE $(addprefix build/loesung-, table.tex a.tex b.tex c.tex d.tex plot.pdf) | build
	TEXINPUTS="$(call translate,build:)" \
	max_print_line=1048576 \
	latexmk \
	  --lualatex \
	  --output-directory=build \
	  --interaction=batchmode \
	  --halt-on-error \
	loesung.tex

build/loesung-plot.pdf: loesung.py curve_fit.py data.txt loesung-matplotlibrc loesung-header-matplotlib.tex | build
	MATPLOTLIBRC=loesung-matplotlibrc \
	TEXINPUTS="$$(pwd):" \
	python loesung.py

$(addprefix build/loesung-, table.tex a.tex b.tex c.tex d.tex): build/loesung-plot.pdf

data.txt: data.py
	python $<

build:
	mkdir -p build

clean:
	rm -rf build
	rm -f data.txt

FORCE:

.PHONY: all clean
