Revision 783
Added by Aaron Marcuse-Kubitza almost 13 years ago
input.Makefile | ||
---|---|---|
1 |
##### Configuration |
|
2 |
|
|
3 |
exts ?= csv xml |
|
4 |
test_n ?= 2 |
|
5 |
tablesSort ?= plots organisms stems |
|
6 |
mainCoreMapTry ?= organisms specimens |
|
7 |
|
|
8 |
##### Vars/functions |
|
9 |
|
|
1 | 10 |
selfDir_uZPPqC := $(dir $(lastword $(MAKEFILE_LIST))) |
2 | 11 |
|
3 | 12 |
# Make |
... | ... | |
16 | 25 |
CP = cp -p |
17 | 26 |
DIFF = diff --unified=2 |
18 | 27 |
|
19 |
# Config |
|
20 |
exts ?= csv xml |
|
21 |
test_n ?= 2 |
|
22 |
tablesSort ?= plots organisms stems |
|
23 |
mainCoreMapTry ?= organisms specimens |
|
24 |
|
|
28 |
# Paths |
|
25 | 29 |
root := $(selfDir_uZPPqC).. |
26 | 30 |
mappings := $(root)/mappings |
27 | 31 |
psqlAsBien := $(root)/bin/psql_vegbien |
28 | 32 |
|
29 |
##### |
|
33 |
##### General targets
|
|
30 | 34 |
|
31 | 35 |
all: _always maps ; |
32 | 36 |
|
... | ... | |
47 | 51 |
$(root)/%: _always |
48 | 52 |
+$(subMake) |
49 | 53 |
|
50 |
##### |
|
54 |
##### SVN
|
|
51 | 55 |
|
52 | 56 |
svn_props: _always |
53 | 57 |
svn propset svn:ignore $$'.~*\n*.log\n*.out\nsrc*' . |
54 | 58 |
$(if $(wildcard test/),svn propset svn:ignore $$'*.out\n*.xml' test) |
55 | 59 |
|
56 |
##### |
|
60 |
##### Installation
|
|
57 | 61 |
|
58 | 62 |
reinstall: _always uninstall install ; |
59 | 63 |
|
60 |
##### |
|
64 |
##### Maps
|
|
61 | 65 |
|
62 | 66 |
allViaMaps := $(filter-out maps/VegBIEN.%.csv,$(wildcard maps/*.csv)) |
63 | 67 |
via := $(firstword $(sort $(basename $(basename $(notdir $(allViaMaps)))))) |
68 |
|
|
64 | 69 |
coreMap := $(mappings)/$(via)-VegBIEN.%.csv |
65 | 70 |
mainCoreMap := $(firstword $(wildcard $(mainCoreMapTry:%=$(coreMap)))) |
71 |
|
|
66 | 72 |
viaMaps := $(wildcard $(tablesSort:%=maps/$(via).%.csv)) |
67 | 73 |
viaMaps += $(filter-out $(viaMaps),$(wildcard maps/$(via).*.csv)) |
74 |
|
|
68 | 75 |
autogenMaps := $(subst $(via).,VegBIEN.,$(viaMaps)) |
69 | 76 |
directMaps := $(autogenMaps) $(filter-out $(autogenMaps),\ |
70 | 77 |
$(wildcard maps/VegBIEN.*.csv)) |
... | ... | |
80 | 87 |
$(root)/bin/join_sort <$+ >$@ |
81 | 88 |
.PRECIOUS: maps/VegBIEN.%.csv $(coreMap) |
82 | 89 |
|
83 |
##### |
|
90 |
##### Mapping
|
|
84 | 91 |
|
85 | 92 |
dbFile := $(firstword $(wildcard src/db.*.sql)) |
86 | 93 |
inputFiles := $(wildcard src/*.csv src/*.xml) |
... | ... | |
90 | 97 |
map = $(if $(<in),<$(<in) ,$(if $(mapEnv),env $(mapEnv) ))$(root)/map $(+maps) |
91 | 98 |
map2db = env out_database=vegbien $(map) |
92 | 99 |
|
93 |
##### |
|
100 |
##### Import to VegBIEN
|
|
94 | 101 |
|
95 | 102 |
ifneq ($(dbFile)$(inputFiles),) |
96 | 103 |
|
... | ... | |
122 | 129 |
rm_logs: _always |
123 | 130 |
$(RM) $(logs) |
124 | 131 |
|
125 |
##### |
|
132 |
##### Verification of import
|
|
126 | 133 |
|
127 | 134 |
ifneq ($(wildcard verify.ref*),) |
128 | 135 |
|
... | ... | |
141 | 148 |
verify: _always ; |
142 | 149 |
endif |
143 | 150 |
|
144 |
##### |
|
151 |
##### Testing
|
|
145 | 152 |
|
146 | 153 |
ifneq ($(wildcard test/),) |
147 | 154 |
|
... | ... | |
199 | 206 |
test: _always ; |
200 | 207 |
endif |
201 | 208 |
|
202 |
##### |
|
209 |
##### Input-type-specific
|
|
203 | 210 |
|
204 | 211 |
# Each input type needs var $(mapEnv) and targets install, uninstall |
205 | 212 |
|
... | ... | |
212 | 219 |
$(inputDbAsBien) $(db) <$< >$@ |
213 | 220 |
.PRECIOUS: %.ref |
214 | 221 |
|
215 |
#### |
|
222 |
#### Installation
|
|
216 | 223 |
|
217 | 224 |
install: _always db ; |
218 | 225 |
|
219 | 226 |
uninstall: _always rm_db ; |
220 | 227 |
|
221 |
#### |
|
228 |
#### DB-engine-specific
|
|
222 | 229 |
|
223 | 230 |
# Each DB engine needs vars $(dbEngine), $(dbAsBien) and targets db, rm_db |
224 | 231 |
|
... | ... | |
242 | 249 |
echo "DROP DATABASE IF EXISTS $(db);"|$(mysqlAsRoot) |
243 | 250 |
# ignore errors if grant not defined |
244 | 251 |
|
245 |
### |
|
252 |
### Unrecognized DB engine
|
|
246 | 253 |
|
247 | 254 |
else |
248 | 255 |
$(error The DB filename $(dbFile) must have the form db.{my|pg}.sql) |
... | ... | |
251 | 258 |
# Must come after dbEngine is set |
252 | 259 |
mapEnv := in_engine=$(dbEngine) in_database=$(db) |
253 | 260 |
|
254 |
#### |
|
261 |
#### Unrecognized input type
|
|
255 | 262 |
|
256 | 263 |
else |
257 | 264 |
install: _always ; |
Also available in: Unified diff
input.Makefile: Added documentation labels to each section