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 2978 aaronmk
all = vegbien.sql vegbien.my.sql functions.sql py_functions.sql
11 387 aaronmk
12 418 aaronmk
all: _always $(all) ;
13 387 aaronmk
14 1260 aaronmk
.SUFFIXES: # turn off built-in suffix rules
15
.SECONDARY: # don't automatically delete intermediate files
16 1354 aaronmk
.DELETE_ON_ERROR: # delete target if recipe fails
17 387 aaronmk
18
_always:
19
.PHONY: _always
20
21
clean: _always
22
	$(RM) $(all)
23
24 785 aaronmk
##### MySQL schema for ERD
25 533 aaronmk
26 809 aaronmk
repl = ../bin/repl
27 541 aaronmk
28 809 aaronmk
%.my.sql: %.sql ../lib/PostgreSQL-MySQL.csv filter_ERD.csv
29
	$(repl) <$(wordlist 1,2,$+)|$(repl) $(word 3,$+) >$@
30 2979 aaronmk
31
##### DDLs
32
33
pg_dump = ../bin/pg_dump_vegbien $(1) >$@
34
35
vegbien.sql:
36
	$(call pg_dump,public)
37
38
py_functions.sql:
39
	env owners=1 $(call pg_dump,py_functions)
40
41
# Must come after %.my.sql so that gets matched first
42
%.sql:
43
	$(call pg_dump,$*)