TEXS = $(wildcard *.tex) NAMES = $(patsubst %.tex,%,$(TEXS)) TEXMK = latexmk -lualatex -shell-escape -interaction=nonstopmode QPDF = qpdf --linearize --replace-input RM = rm -rf all: build build: $(foreach i,$(TEXS),$(TEXMK) "$(i)";) @$(foreach i,$(NAMES),$(QPDF) "$(i).pdf" 2>/dev/null |:;) EXTS = aux fdb_latexmk fls log nav out snm synctex.gz toc vrb clean: $(RM) $(foreach f,$(NAMES),$(foreach ext,$(EXTS),$(f).$(ext))) full-clean: clean $(RM) $(foreach f,$(NAMES),$(f).pdf)