LATEXMK ?= latexmk
FLAGS := -norc -pdf -no-shell-escape
FLAGS += -interaction=nonstopmode -halt-on-error
.DELETE_ON_ERROR:
.DEFAULT_GOAL := all
DOCS := article notes
PDFS := $(addsuffix /main.pdf,$(addprefix build/,$(DOCS)))
.PHONY: all
all: $(PDFS)
build/%/main.pdf: %.tex
	@mkdir -p $(@D)
	@$(LATEXMK) $(FLAGS) -outdir=$(@D) -jobname=main $< > $(@D)/latexmk.log 2>&1 || \
	  { cat $(@D)/latexmk.log >&2; exit 1; }
