EXAMPLES = $(wildcard *.py) FIRSTLOGS = ${EXAMPLES:.py=_1.log} LASTLOGS = ${EXAMPLES:.py=_2.log} .PHONY: all .SECONDAY: $(FIRSTLOGS) all: $(LASTLOGS) %_1.log: %.py rm -f *.json *.pickle python3 $< > $@ %_2.log: %.py %_1.log python3 $< > $@ rm -f *.json *.pickle clean: @echo "\e[1m * Example logs...\e[0m" @rm -f $(FIRSTLOGS) $(LASTLOGS) *.json *.pickle