1
|
selfDir_3d1bc249 := $(dir $(lastword $(MAKEFILE_LIST)))
|
2
|
|
3
|
vegxMaps := $(wildcard map.VegX.*.csv)
|
4
|
vegbienMaps := $(subst .VegX.,.VegBIEN.,$(vegxMaps))
|
5
|
|
6
|
table = $(shell s="$(*F)"; echo "$${s\#\#*.}")# remove sort order prefix
|
7
|
|
8
|
root := ../..
|
9
|
map := env out_database=vegbien $(root)/map
|
10
|
|
11
|
#####
|
12
|
|
13
|
all: _not_file # empty rule since must be first target in file
|
14
|
|
15
|
.SUFFIXES:
|
16
|
|
17
|
_not_file:
|
18
|
.PHONY: _not_file
|
19
|
|
20
|
all := $(wildcard output.*) $(vegbienMaps)
|
21
|
|
22
|
clean: _not_file
|
23
|
$(RM) $(all)
|
24
|
|
25
|
#####
|
26
|
|
27
|
reinstall: _not_file uninstall install
|
28
|
|
29
|
#####
|
30
|
|
31
|
map.VegBIEN.%.csv: map.VegX.%.csv
|
32
|
$(root)/bin/join_sort <$< $(root)/mappings/VegX-VegBIEN.$(table).csv >$@
|
33
|
.PRECIOUS: map.VegBIEN.%.csv
|
34
|
|
35
|
logs := $(wildcard *.log)
|
36
|
|
37
|
rm_logs: _not_file
|
38
|
$(RM) $(logs)
|
39
|
|
40
|
#####
|
41
|
|
42
|
ifdef db
|
43
|
|
44
|
ifndef dbEngine
|
45
|
$(error dbEngine variable must be set. Possible values: MySQL, PostgreSQL)
|
46
|
endif
|
47
|
|
48
|
mapEnv := in_engine=$(dbEngine) in_database=$(db)
|
49
|
|
50
|
all: _not_file $(vegbienMaps:map.VegBIEN.%.csv=import-%)
|
51
|
|
52
|
log = $*$(if $(n),.n=$(n),).log
|
53
|
|
54
|
import-%: map.VegBIEN.%.csv _not_file
|
55
|
(set -x; "time" env commit=1 $(mapEnv) $(map) $<) 2>&1 | tee -a $(log)
|
56
|
|
57
|
##
|
58
|
|
59
|
install: _not_file db
|
60
|
|
61
|
uninstall: _not_file rm_db
|
62
|
|
63
|
bienPassword := $(shell cat $(root)/config/bien_password)
|
64
|
mysql := mysql --user=root --password='$(bienPassword)'
|
65
|
|
66
|
db: $(db).sql _not_file
|
67
|
-$(mysql) <$<
|
68
|
echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysql)
|
69
|
# ignore errors in db import so that GRANT will still be run
|
70
|
|
71
|
rm_db: _not_file
|
72
|
-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysql)
|
73
|
echo "DROP DATABASE IF EXISTS $(db);"|$(mysql)
|
74
|
# ignore errors about no such grant being defined
|
75
|
|
76
|
#####
|
77
|
|
78
|
else
|
79
|
$(error db variable must be set)
|
80
|
endif
|