
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules

main_tex ?= paper

VERSION_STRING := $(shell git describe --tags --long)

all: ${main_tex}.pdf

%.pdf: %.tex paper.bib version.tex
	pdflatex -shell-escape $<
	biber $* 
	pdflatex -shell-escape $<

paper_biber.bib:
	biber --output-format=bibtex --output-resolve paper.bcf

submission.zip:
	rm -f submission.zip
	zip -r submission.zip paper.tex paper.bib version.tex \
		figures/klein-spulen-schwingkreise-korbspule.jpg\
		figures/k_ripple_plot.pdf\
		figures/nk_combined.pdf\
		figures/nk_complex_illust.pdf\
		figures/rms_ripple_double_rotation_n3_r4.pdf\
		figures/saacke-radiotechnik-3-ledionspule.jpg\
		figures/svg_vis_paper_plain.png\
		figures/svg_vis_paper.png\
		figures/symmetry_3turn_n_twist.pdf\
		figures/test_schematic.pdf\
		figures/setup_probe_small.jpg

version.tex: ${main_tex}.tex paper.bib
	echo -n "${VERSION_STRING}" > $@

.PHONY: clean
clean:
	rm -f ${main_tex}.aux ${main_tex}.bbl ${main_tex}.bcf ${main_tex}.log ${main_tex}.blg
	rm -f ${main_tex}.out ${main_tex}.run.xml texput.log 

