1
|
selfDir_AkFFYJ := $(dir $(lastword $(MAKEFILE_LIST)))
|
2
|
root := $(selfDir_AkFFYJ)..
|
3
|
include $(root)/lib/common.Makefile
|
4
|
|
5
|
|
6
|
##### Vars/functions
|
7
|
|
8
|
# OS
|
9
|
os = $(shell uname)
|
10
|
|
11
|
SED = sed -$(if $(filter Darwin,$(os)),E,r)
|
12
|
|
13
|
##### General targets
|
14
|
|
15
|
all = vegbien.sql vegbien.my.sql functions.sql py_functions.sql
|
16
|
|
17
|
all: _always $(all) ;
|
18
|
|
19
|
clean: _always
|
20
|
$(RM) $(all)
|
21
|
|
22
|
##### MySQL schema for ERD
|
23
|
|
24
|
repl = ../bin/repl
|
25
|
|
26
|
%.my.sql: %.sql ../lib/PostgreSQL-MySQL.csv filter_ERD.csv
|
27
|
$(repl) <$(wordlist 1,2,$+)|$(repl) $(word 3,$+) >$@
|
28
|
|
29
|
##### DDLs
|
30
|
|
31
|
pg_dump = env schema= ../bin/pg_dump_vegbien $(1) >$@
|
32
|
|
33
|
vegbien.sql:
|
34
|
$(call pg_dump,public)
|
35
|
|
36
|
py_functions.sql:
|
37
|
env owners=1 $(call pg_dump,py_functions)
|
38
|
|
39
|
# Must come after %.my.sql so that gets matched first
|
40
|
%.sql:
|
41
|
$(call pg_dump,$*)
|