Project

General

Profile

1
##### Vars/functions
2

    
3
# OS
4
os = $(shell uname)
5

    
6
SED = sed -$(if $(filter Darwin,$(os)),E,r)
7

    
8
##### General targets
9

    
10
all = vegbien.sql vegbien_empty.sql vegbien.my.sql
11

    
12
all: _always $(all) ;
13

    
14
.SUFFIXES: # turn off built-in suffix rules
15
.SECONDARY: # don't automatically delete intermediate files
16

    
17
_always:
18
.PHONY: _always
19

    
20
clean: _always
21
	$(RM) $(all)
22

    
23
%:: %.make
24
	./$< >$@
25

    
26
##### VegBIEN DB
27

    
28
empty = $(SED) -n \
29
's/^CREATE TABLE ([0-9A-Za-z_]+) \($$/TRUNCATE \1 CASCADE;/p' <$< >$@
30

    
31
%_empty.sql: %.sql
32
	$(empty)
33

    
34
##### MySQL schema for ERD
35

    
36
repl = ../bin/repl
37

    
38
%.my.sql: %.sql ../lib/PostgreSQL-MySQL.csv filter_ERD.csv
39
	$(repl) <$(wordlist 1,2,$+)|$(repl) $(word 3,$+) >$@
(2-2/14)