TEXSRC = $(wildcard blatt*.tex) TEXTRG = $(TEXSRC:%.tex=%.pdf) .PHONY: all clean all: $(TEXTRG) clean: -rm -f blatt*.pdf blatt*.log blatt*.aux RERUN_REGEX = "(There were undefined references|Rerun to get .* right)" %.pdf: %.tex pdflatex $< egrep $(RERUN_REGEX) $(@:%.pdf=%.log) >/dev/null && pdflatex $<; true