doc := test all: $(doc).final %.final: %.step-two cp $< $@ echo done >> $@ %.step-two: %.step-one.1 %.step-one.2 %.step-one.3 %.step-one.4 cat $^ > $@ $(if $(use-intermediate-rule), \ $(eval .INTERMEDIATE: $(addprefix $(doc),.step-one.2 .step-one.3 .step-one.4)) \ ) %.step-one.1 %.step-one.2 %.step-one.3 %.step-one.4: %.input $(this-makefile) cp $< $*.step-one.1 cp $< $*.step-one.2 cp $< $*.step-one.3 cp $< $*.step-one.4 %.input: echo hi > $@ .PHONY: clean clean: rm -f $(addprefix $(doc),.step-one.2 .step-one.3 .step-one.4 .step-one.1 .final .step-two)