Project

General

Profile

1
selfDir_3d1bc249 := $(dir $(lastword $(MAKEFILE_LIST)))
2

    
3
vegxMaps := $(wildcard map.VegX.*.csv)
4
vegbienMaps := $(subst .VegX.,.VegBIEN.,$(vegxMaps))
5

    
6
root := ../..
7
util := $(root)/util
8
mappings := $(root)/mappings
9
map := $(root)/map
10
map2vegbien := env out_database=vegbien $(map)
11

    
12
#####
13

    
14
all: _not_file # empty rule since must be first target in file
15

    
16
.SUFFIXES:
17

    
18
_not_file:
19
.PHONY: _not_file
20

    
21
all := $(wildcard output.*) $(vegbienMaps)
22

    
23
clean: _not_file
24
	$(RM) $(all)
25

    
26
#####
27

    
28
reinstall: _not_file uninstall install
29

    
30
#####
31

    
32
map.VegBIEN.%.csv: map.VegX.%.csv
33
	$(util)/join_sort <$< $(mappings)/VegX-VegBIEN.$(*F).csv >$@
34
.PRECIOUS: map.VegBIEN.%.csv
35

    
36
#####
37

    
38
ifdef db
39

    
40
ifndef dbEngine
41
$(error dbEngine variable must be set. Possible values: MySQL, PostgreSQL)
42
endif
43

    
44
mapEnv := in_engine=$(dbEngine) in_database=$(db)
45

    
46
all: _not_file $(vegbienMaps:%=from_db-%)
47

    
48
from_db-%: % _not_file
49
	env $(mapEnv) $(map2vegbien) $<
50

    
51
##
52

    
53
install: _not_file db
54

    
55
uninstall: _not_file rm_db
56

    
57
bienPassword := $(shell cat $(util)/bien_password)
58
mysql := mysql --user=root --password='$(bienPassword)'
59

    
60
db: $(db).sql _not_file
61
	-$(mysql) <$<
62
	echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysql)
63
# ignore errors in db import so that GRANT will still be run
64

    
65
rm_db: _not_file
66
	-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysql)
67
	echo "DROP DATABASE IF EXISTS $(db);"|$(mysql)
68
# ignore errors about no such grant being defined
69

    
70
#####
71

    
72
else
73
$(error db variable must be set)
74
endif
(5-5/18)