LATEXMK ?= latexmk
FLAGS := -norc -pdf -no-shell-escape
FLAGS += -interaction=nonstopmode -halt-on-error
.DELETE_ON_ERROR:
.DEFAULT_GOAL := all
CHAPTERS := $(wildcard sections/*.tex)
.PHONY: all
all: build/main.pdf
build/main.pdf: main.tex $(CHAPTERS) | build
	@printf "compile document and chapters\n"
	@$(LATEXMK) $(FLAGS) -outdir=build main.tex > build/latexmk.log 2>&1 || \
	  { cat build/latexmk.log >&2; exit 1; }
build:
	@mkdir -p $@
