aboutsummaryrefslogtreecommitdiff
path: root/common.mk
blob: 3770740e263037442656ee9c065024e6fe850718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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