doc := test all: $(doc).pdf this-makefile := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) %.pdf: %.ps ps2pdf $< %.ps: %.dvi %.aux %.log %.out dvips -Ppdf -t a4 -o $@ $< $(if $(use-intermediate-rule), \ $(eval .INTERMEDIATE: $(addprefix $(doc),.aux .log .out)) \ ) %.dvi %.aux %.log %.out: %.tex $(this-makefile) latex $< latex $< # Second invocation for cross references .PHONY: clean clean: rm -f $(addprefix $(doc),.aux .log .out .dvi .pdf .ps)