RM = rm -f MYSQL = mysql -H mysql M4 = m4 RESET_SQL += reset.sql QUERY_SQL += $(wildcard q*.sql) TESTS_SQL += $(wildcard t*.sql) TESTS_MD = $(patsubst %.sql,%.md, $(TESTS_SQL)) .PHONY: clean all: $(TARGET).md .tmp.sql: $(RESET_SQL) $(QUERY_SQL) cat $(RESET_SQL) $(QUERY_SQL) > .tmp.sql reset: .tmp.sql $(MYSQL) < .tmp.sql %.md: %.sql reset $(MYSQL) < $< &> $@ $(TARGET).md: $(TESTS_MD) $(TARGET).m4 $(M4) $(TARGET).m4 > $(TARGET).md clean: $(RM) $(wildcard *.md) .tmp.sql