LATEXMK ?= latexmk
FLAGS := -norc -pdf -no-shell-escape
FLAGS += -interaction=nonstopmode -halt-on-error
.DELETE_ON_ERROR:
.DEFAULT_GOAL := all
.PHONY: all
all: build/main.pdf
tables/rows.tex: data.tsv | tables
	@printf "generate table rows\n"
	@awk '{printf "%s & %d \\\\\n", $$1, $$2}' $< > $@.tmp && mv $@.tmp $@
build/main.pdf: main.tex tables/rows.tex | build
	@printf "compile document with table\n"
	@$(LATEXMK) $(FLAGS) -outdir=build main.tex > build/latexmk.log 2>&1 || \
	  { cat build/latexmk.log >&2; exit 1; }
build tables:
	@mkdir -p $@
