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 functions.sql
11

    
12
all: _always $(all) ;
13

    
14
.SUFFIXES: # turn off built-in suffix rules
15
.SECONDARY: # don't automatically delete intermediate files
16
.DELETE_ON_ERROR: # delete target if recipe fails
17

    
18
_always:
19
.PHONY: _always
20

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

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

    
27
##### VegBIEN DB
28

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

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

    
35
##### MySQL schema for ERD
36

    
37
repl = ../bin/repl
38

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