LATEXMK ?= latexmk
FLAGS := -norc -pdf -no-shell-escape
FLAGS += -interaction=nonstopmode -halt-on-error
.DELETE_ON_ERROR:
.DEFAULT_GOAL := all
.PHONY: all clean distclean
all: build/main.pdf
build/main.pdf: main.tex | build
	@$(LATEXMK) $(FLAGS) -outdir=build main.tex > build/latexmk.log 2>&1 || \
	  { cat build/latexmk.log >&2; exit 1; }
build:
	@mkdir -p $@
clean:
	@$(LATEXMK) -norc -c -outdir=build main.tex > cleanup.log 2>&1 || \
	  { cat cleanup.log >&2; exit 1; }
distclean: clean
	@rm -rf -- build
