Project

General

Profile

1 785 aaronmk
##### Vars/functions
2
3 387 aaronmk
# OS
4
os = $(shell uname)
5
6
SED = sed -$(if $(filter Darwin,$(os)),E,r)
7
8 785 aaronmk
##### General targets
9 387 aaronmk
10 692 aaronmk
all = vegbien.sql vegbien_empty.sql vegbien.my.sql
11 387 aaronmk
12 418 aaronmk
all: _always $(all) ;
13 387 aaronmk
14
.SUFFIXES:
15
16
_always:
17
.PHONY: _always
18
19
clean: _always
20
	$(RM) $(all)
21
22 423 aaronmk
remake: _always clean all ;
23
24 387 aaronmk
%:: %.make
25
	./$< >$@
26
.PRECIOUS: %
27
28 785 aaronmk
##### VegBIEN DB
29 387 aaronmk
30
.PRECIOUS: vegbien.sql
31
32
empty = $(SED) -n \
33
's/^CREATE TABLE ([0-9A-Za-z_]+) \($$/TRUNCATE \1 CASCADE;/p' <$< >$@
34
35
%_empty.sql: %.sql
36
	$(empty)
37 533 aaronmk
38 785 aaronmk
##### MySQL schema for ERD
39 533 aaronmk
40 809 aaronmk
repl = ../bin/repl
41 541 aaronmk
42 809 aaronmk
%.my.sql: %.sql ../lib/PostgreSQL-MySQL.csv filter_ERD.csv
43
	$(repl) <$(wordlist 1,2,$+)|$(repl) $(word 3,$+) >$@