TEXC = latexmk -lualatex -output-directory=build

.PHONY: FORCE

pdf: build/main.pdf

build/%.pdf: %.tex FORCE
	$(TEXC) -latexoption=-shell-escape $<
	cp build/main.pdf build/main.tmp.pdf
	gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=build/main.pdf build/main.tmp.pdf
	rm build/main.tmp.pdf

clean: FORCE
	$(TEXC) -c

clean_all: FORCE
	$(RM) -fr build
