Revision 264
Added by Aaron Marcuse-Kubitza almost 13 years ago
scripts/util/inputs_Makefile | ||
---|---|---|
1 | 1 |
selfDir_3d1bc249 := $(dir $(lastword $(MAKEFILE_LIST))) |
2 | 2 |
|
3 |
mysql := mysql --user=root --password='$(shell cat \
|
|
4 |
$(selfDir_3d1bc249)/bien_password)'
|
|
3 |
vegxMaps := $(wildcard map.VegX.*.csv)
|
|
4 |
vegbienMaps := $(subst .VegX.,.VegBIEN.,$(vegxMaps))
|
|
5 | 5 |
|
6 |
root := ../.. |
|
7 |
scripts := $(root)/scripts |
|
8 |
util := $(scripts)/util |
|
9 |
mappings := $(root)/mappings |
|
10 |
map := $(scripts)/bien_map |
|
11 |
map2vegbien := env out_database=vegbien $(map) |
|
12 |
|
|
6 | 13 |
##### |
7 | 14 |
|
8 | 15 |
all: _not_file # empty rule since must be first target in file |
... | ... | |
12 | 19 |
_not_file: |
13 | 20 |
.PHONY: _not_file |
14 | 21 |
|
15 |
all =
|
|
22 |
all := $(wildcard output.*) $(vegbienMaps)
|
|
16 | 23 |
|
17 | 24 |
clean: _not_file |
18 | 25 |
$(RM) $(all) |
19 | 26 |
|
20 | 27 |
##### |
21 | 28 |
|
29 |
reinstall: _not_file uninstall install |
|
30 |
|
|
31 |
##### |
|
32 |
|
|
33 |
map.VegBIEN.%.csv: map.VegX.%.csv |
|
34 |
$(util)/join_sort <$< $(mappings)/VegX-VegBIEN.$(*F).csv >$@ |
|
35 |
.PRECIOUS: map.VegBIEN.%.csv |
|
36 |
|
|
37 |
##### |
|
38 |
|
|
22 | 39 |
ifdef db |
23 | 40 |
|
24 | 41 |
ifndef dbEngine |
25 | 42 |
$(error dbEngine variable must be set. Possible values: MySQL, PostgreSQL) |
26 | 43 |
endif |
27 | 44 |
|
28 |
all = db.sh
|
|
45 |
mapEnv := in_engine=$(dbEngine) in_database=$(db)
|
|
29 | 46 |
|
30 |
all: _not_file $(all)
|
|
47 |
all: _not_file $(vegbienMaps:%=from_db-%)
|
|
31 | 48 |
|
32 |
db.sh:
|
|
33 |
echo 'engine=$(dbEngine) database=$(db)' >$@
|
|
49 |
from_db-%: % _not_file
|
|
50 |
env $(mapEnv) $(map2vegbien) $<
|
|
34 | 51 |
|
35 |
###
|
|
52 |
## |
|
36 | 53 |
|
37 | 54 |
install: _not_file all db |
38 | 55 |
|
39 | 56 |
uninstall: _not_file rm_db clean |
40 | 57 |
|
58 |
bienPassword := $(shell cat $(util)/bien_password) |
|
59 |
mysql := mysql --user=root --password='$(bienPassword)' |
|
60 |
|
|
41 | 61 |
db: $(db).sql _not_file |
42 | 62 |
-$(mysql) <$< |
43 | 63 |
echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysql) |
... | ... | |
53 | 73 |
else |
54 | 74 |
$(error db variable must be set) |
55 | 75 |
endif |
56 |
|
|
57 |
reinstall: _not_file uninstall install |
Also available in: Unified diff
inputs_Makefile: Auto-generate map to VegBIEN and import data into vegbien from input DB