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 |
2620
|
aaronmk
|
all = vegbien.sql vegbien_empty.sql vegbien.my.sql functions.sql\
|
11 |
|
|
py_functions.sql
|
12 |
387
|
aaronmk
|
|
13 |
418
|
aaronmk
|
all: _always $(all) ;
|
14 |
387
|
aaronmk
|
|
15 |
1260
|
aaronmk
|
.SUFFIXES: # turn off built-in suffix rules
|
16 |
|
|
.SECONDARY: # don't automatically delete intermediate files
|
17 |
1354
|
aaronmk
|
.DELETE_ON_ERROR: # delete target if recipe fails
|
18 |
387
|
aaronmk
|
|
19 |
|
|
_always:
|
20 |
|
|
.PHONY: _always
|
21 |
|
|
|
22 |
|
|
clean: _always
|
23 |
|
|
$(RM) $(all)
|
24 |
|
|
|
25 |
|
|
%:: %.make
|
26 |
|
|
./$< >$@
|
27 |
|
|
|
28 |
785
|
aaronmk
|
##### VegBIEN DB
|
29 |
387
|
aaronmk
|
|
30 |
|
|
empty = $(SED) -n \
|
31 |
|
|
's/^CREATE TABLE ([0-9A-Za-z_]+) \($$/TRUNCATE \1 CASCADE;/p' <$< >$@
|
32 |
|
|
|
33 |
|
|
%_empty.sql: %.sql
|
34 |
|
|
$(empty)
|
35 |
533
|
aaronmk
|
|
36 |
785
|
aaronmk
|
##### MySQL schema for ERD
|
37 |
533
|
aaronmk
|
|
38 |
809
|
aaronmk
|
repl = ../bin/repl
|
39 |
541
|
aaronmk
|
|
40 |
809
|
aaronmk
|
%.my.sql: %.sql ../lib/PostgreSQL-MySQL.csv filter_ERD.csv
|
41 |
|
|
$(repl) <$(wordlist 1,2,$+)|$(repl) $(word 3,$+) >$@
|