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:
15

    
16
_always:
17
.PHONY: _always
18

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

    
22
remake: _always clean all ;
23

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

    
28
##### VegBIEN DB
29

    
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

    
38
##### MySQL schema for ERD
39

    
40
repl = ../bin/repl
41

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