AUX ?= aux FILE ?= contents.latex FLAGS ?= -interaction=batchmode AUXFILE = $(AUX)/$(addsuffix ".aux", $(basename $(FILE))) TARGET = $(addsuffix ".pdf", $(basename $(FILE))) all: $(TARGET) $(TARGET): $(FILE) mkdir -p $(AUX) pdflatex $(FLAGS) -output-directory=$(AUX) $(FILE) bibtex $(AUXFILE) pdflatex $(FLAGS) -output-directory=$(AUX) $(FILE) pdflatex $(FLAGS) -output-directory=$(AUX) $(FILE) cp $(AUX)/$(TARGET) . clean: rm -r $(TARGET) $(AUX) .PHONY: all clean