CXXFLAGS := -std=c++11 -Wall -Wextra -O2 progs := $(patsubst %.cc,%,$(wildcard d*.cc)) .PHONY: all all: $(addsuffix _output.txt,$(progs)) .PHONY: clean clean: rm -f $(progs) $(addsuffix _test.txt,$(progs)) .PHONY: ok-% ok-%: %_test.txt @cp -v $< $*_output.txt .PHONY: test-% test-%: %_output.txt %_output.txt: %_test.txt @test -f $@ || (echo $*:; cat $<) @test -f $@ && (diff -u $@ $< && touch $@) || exit 0 $(addsuffix _test.txt,$(progs)): %_test.txt: % %_input.txt ./$< < $*_input.txt > $@