Project

General

Profile

1 783 aaronmk
##### Configuration
2
3 1921 aaronmk
# Command line
4 1190 aaronmk
log ?= $(if $(test),,1)
5 1257 aaronmk
profile ?=
6 1983 aaronmk
quiet ?=
7 1620 aaronmk
reverify ?= 1
8 1990 aaronmk
use_staged ?= $(by_col)
9 1921 aaronmk
10
# Makefile
11
tablesSort ?= plots organisms stems specimens
12 1386 aaronmk
exts ?= csv tsv txt xml
13 783 aaronmk
test_n ?= 2
14
15
##### Vars/functions
16
17 640 aaronmk
selfDir_uZPPqC := $(dir $(lastword $(MAKEFILE_LIST)))
18 250 aaronmk
19 1821 aaronmk
# Paths
20
datasrc := $(notdir $(realpath .))
21
root := $(selfDir_uZPPqC)..
22
bin := $(root)/bin
23
mappings := $(root)/mappings
24
25 368 aaronmk
# Make
26 640 aaronmk
SHELL := /bin/bash
27 1509 aaronmk
selfMake = $(MAKE) --makefile=../input.Makefile
28 1821 aaronmk
subMake = $(MAKE) $(@:$(root)/%=%) --directory=$(root)
29 404 aaronmk
+_ = $(+:_%=)
30 368 aaronmk
addBeforeExt = $(basename $(2))$(1)$(suffix $(2))
31
32 1742 aaronmk
# OS
33
os := $(shell uname)
34
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1))
35
36
# Formatting
37
SED = sed -$(if $(filter Darwin,$(os)),E,r)
38
39 790 aaronmk
# System
40
date = $(shell date +"%Y-%m-%d-%H-%M-%S")
41
42 640 aaronmk
# Terminal
43 1184 aaronmk
termCols := $(shell tput cols)
44 640 aaronmk
esc := '['
45
reset := $(esc)'0m'
46
emph := $(esc)'7m '
47
endEmph := ' '$(reset)
48
49 368 aaronmk
# Commands
50 1245 aaronmk
MKDIR = mkdir -p
51
mkdir = $(MKDIR) $(@D)
52 395 aaronmk
CP = cp -p
53 1184 aaronmk
diff = diff --unified=2
54
diffVerbose = $(if $(verbose),diff --side-by-side --left-column\
55
--width=$(termCols),$(diff))
56 368 aaronmk
57 1918 aaronmk
# BIEN commands
58 1524 aaronmk
selfMap = $(bin)/cols 0 0
59 1081 aaronmk
psqlOpts := --set ON_ERROR_STOP=1 --quiet
60 1289 aaronmk
psqlAsBien := $(bin)/psql_vegbien $(psqlOpts)
61 353 aaronmk
62 1594 aaronmk
# SVN
63
addDir = $(if $(wildcard $(1)/),svn add --depth=empty $(1),svn mkdir $(1))
64 1771 aaronmk
setSvnIgnore = svn propset svn:ignore $(2) $(1)
65 1594 aaronmk
define addDirWithIgnore
66
$(addDir)
67 1771 aaronmk
$(setSvnIgnore)
68 1594 aaronmk
endef
69
70 783 aaronmk
##### General targets
71 250 aaronmk
72 418 aaronmk
all: _always maps ;
73 247 aaronmk
74 1260 aaronmk
.SUFFIXES: # turn off built-in suffix rules
75
.SECONDARY: # don't automatically delete intermediate files
76 1354 aaronmk
.DELETE_ON_ERROR: # delete target if recipe fails
77 247 aaronmk
78 383 aaronmk
_always:
79
.PHONY: _always
80 250 aaronmk
81 383 aaronmk
clean: _always
82 256 aaronmk
	$(RM) $(all)
83
84 1742 aaronmk
remake: _always clean
85
	+$(selfMake)
86
# re-run make so that cache of existing files is reset
87
88 1627 aaronmk
make_script = ./$< >$@
89 368 aaronmk
90 1604 aaronmk
%/: % _always ;
91
92 1627 aaronmk
# Must come before `%: %.make` to override it
93
src/%: src/%.make _always
94 3317 aaronmk
	(set -x; $(make_script)) 2>>$<.log.sql
95 1627 aaronmk
.PRECIOUS: src/% # save partial outputs of aborted src make scripts
96
97
%: %.make _always
98
	$(make_script)
99
100 783 aaronmk
##### SVN
101 250 aaronmk
102 1594 aaronmk
add: _always
103 1771 aaronmk
	$(call setSvnIgnore,.,$$'')
104 1594 aaronmk
	$(call addDirWithIgnore,src,$$'*')
105
	$(call addDirWithIgnore,maps,$$'.~*')
106
	$(call addDirWithIgnore,import,$$'*')
107
	$(call addDirWithIgnore,test,$$'*.out\n*.xml')
108
	$(call addDirWithIgnore,verify,$$'*.out')
109 766 aaronmk
110 1969 aaronmk
##### Existing maps discovery
111 1955 aaronmk
112
inputFiles := $(wildcard $(exts:%=src/*.%))
113
ifeq ($(inputFiles),)
114
dbExport := $(firstword $(wildcard src/db.*.sql))
115
endif
116
117 3574 aaronmk
srcMaps := $(wildcard maps/src.*.csv)
118
srcRoots := $(srcMaps:maps/src.%.csv=$(mappings)/roots/%.sh)
119
120 1289 aaronmk
srcMap := maps/src.%.csv
121 1139 aaronmk
fullViaMap := maps/%.full.csv
122 1289 aaronmk
directMap := maps/VegBIEN.%.csv
123
allViaMaps := $(filter-out $(srcMap) $(fullViaMap) $(directMap),\
124 1139 aaronmk
$(wildcard maps/*.csv))
125 728 aaronmk
via := $(firstword $(sort $(basename $(basename $(notdir $(allViaMaps))))))
126 783 aaronmk
127 3574 aaronmk
# Look up via in src maps' roots
128
ifeq ($(via),)
129
ifneq ($(srcRoots),)
130
via := $(firstword $(sort\
131
$(shell $(SED) -n 's/^export out_root="([0-9A-Za-z_-]+).*$$/\1/p' $(srcRoots))))
132
endif
133
endif
134
135 775 aaronmk
coreMap := $(mappings)/$(via)-VegBIEN.%.csv
136 1524 aaronmk
coreSelfMap := $(mappings)/$(via).self.%.csv
137 783 aaronmk
138 749 aaronmk
viaMaps := $(wildcard $(tablesSort:%=maps/$(via).%.csv))
139 3574 aaronmk
viaMaps += $(filter-out $(viaMaps),$(srcMaps:maps/src.%=maps/$(via).%))
140 1139 aaronmk
viaMaps += $(filter-out $(viaMaps) $(fullViaMap),$(wildcard maps/$(via).*.csv))
141 783 aaronmk
142 728 aaronmk
autogenMaps := $(subst $(via).,VegBIEN.,$(viaMaps))
143
directMaps := $(autogenMaps) $(filter-out $(autogenMaps),\
144
$(wildcard maps/VegBIEN.*.csv))
145 772 aaronmk
tables := $(directMaps:maps/VegBIEN.%.csv=%)
146 728 aaronmk
147 1969 aaronmk
##### Sources
148
149
srcs = $(shell $(bin)/sort_filenames $(wildcard $(exts:%=src/*.$*.%)))
150
isCsv = $(if $(srcs),$(if $(filter %.xml,$(srcs)),,1))
151
    # true if $(srcs) non-empty and contains no *.xml
152
catSrcs = $(bin)/cat$(if $(isCsv),_csv) $(srcs)
153
withCatSrcs = $(catSrcs:$(bin)/%=$(bin)/with_%) --
154
155 1986 aaronmk
# Usage: `make {--silent|-s} inputs/<datasrc>/cat` (don't echo make commands)
156 1969 aaronmk
cat: $(addprefix cat-,$(tables)) _always ;
157
158
cat-%: _always
159
	$(catSrcs)
160
161 1921 aaronmk
##### Installation
162
163
install: _always src/install import/install ;
164
165
uninstall: _always import/uninstall src/uninstall ;
166
167
reinstall: _always uninstall install ;
168
169
##### Staging tables
170
171
import/install: _always import/schema $(addprefix import/install-,$(tables)) ;
172
173
import/uninstall: _always import/rm_schema ;
174
# rm_schema will also drop all staging tables
175
176
import/schema: _always
177
	-echo 'CREATE SCHEMA "$(datasrc)";'|$(psqlAsBien)
178
# ignore errors if schema exists
179
180
import/rm_schema: _always
181
	echo 'DROP SCHEMA IF EXISTS "$(datasrc)" CASCADE;'|$(psqlAsBien)
182
183
import/install-%: _always
184 1955 aaronmk
	$(if $(isCsv),$(import_install_))
185 3476 aaronmk
import_install_ = (prefix=; . $(bin)/vegbien_dest; "time" nice -n +5\
186
env schema=$(datasrc) table=$* $(bin)/csv2db $(catSrcs)\
187 3317 aaronmk
$(if $(log),$(if $(quiet),&>,2>&1|tee )import/install-$*.log.sql))
188 1921 aaronmk
189 1777 aaronmk
##### Maps building
190
191 1789 aaronmk
# Maps to (try to) build are added to one of these
192 1779 aaronmk
maps :=
193 1789 aaronmk
createOnlyMaps :=
194 1779 aaronmk
195 3569 aaronmk
srcRoot = $(mappings)/roots/$*.sh
196
mkSrcMap = $(catSrcs)|(. $(srcRoot); env datasrc=$(datasrc) $(bin)/src_map >$@)
197 1779 aaronmk
198 3567 aaronmk
# Src maps cleanup
199
ifneq ($(filter maps/.%.last_cleanup,$(MAKECMDGOALS)),)
200
maps/.src.%.csv.last_cleanup: maps/src.%.csv
201
	$(bin)/in_place $< $(bin)/cols '*'
202
	touch $@
203
else
204 1779 aaronmk
# Autogen src maps with known table names
205 3567 aaronmk
maps/src.%.csv: _always
206
	$(if $(wildcard $@),,$(if $(isCsv),$(mkSrcMap)))
207
	+$(if $(isCsv),$(selfMake) $(@:maps/%=maps/.%.last_cleanup))
208
# only build if doesn't exist
209 1779 aaronmk
# only build if CSV srcs exist for that table name
210 3567 aaronmk
endif
211
212 1779 aaronmk
# Try all table names
213 1789 aaronmk
createOnlyMaps += $(tablesSort:%=maps/src.%.csv)
214 1779 aaronmk
215 1273 aaronmk
# Must come before $(root)/% to override it
216 1524 aaronmk
$(coreSelfMap): _always
217 1273 aaronmk
	-+$(subMake)
218 1524 aaronmk
# ignore errors if $(coreSelfMap) does not exist
219 1273 aaronmk
220 3561 aaronmk
joinSrcMap = $(if $(hasSrc),$(bin)/in_place $@ $(bin)/intersect $(word 3,$+) 0)
221
hasSrc = $(shell test -s $(word 3,$+) && echo t)
222 1526 aaronmk
223 1273 aaronmk
makeFullCsv = $(if $(shell test -e $(word 2,$+) && echo t),\
224 3561 aaronmk
env ignore=1 $(bin)/union <$(wordlist 1,2,$+)|,<$< )$(bin)/sort_map >$@
225 1524 aaronmk
# can't use $(wildcard) because it won't recheck file after $(coreSelfMap) runs
226 1273 aaronmk
227 3572 aaronmk
# Must come before maps/$(via).%.csv to override it
228 3561 aaronmk
maps/$(via).%.full.csv: maps/$(via).%.csv $(coreSelfMap) $(srcMap)
229 1273 aaronmk
	$(makeFullCsv)
230 1526 aaronmk
	$(joinSrcMap)
231 1139 aaronmk
maps += $(patsubst maps/%.csv,maps/%.full.csv,$(viaMaps))
232
233 3572 aaronmk
# Via maps cleanup
234
ifneq ($(filter maps/.%.last_cleanup,$(MAKECMDGOALS)),)
235
maps/.$(via).%.csv.last_cleanup: maps/$(via).%.csv $(coreMap)
236
	$(bin)/in_place $< env ignore=1 $(bin)/subtract $(word 2,$+) 0 1 2
237
	touch $@
238
# Include comment column so commented mappings are never removed
239
else
240 3574 aaronmk
maps/$(via).%.csv: maps/src.%.csv _always
241
	$(if $(wildcard $@),,$(if $(wildcard $<),$(CP) $< $@))
242 3572 aaronmk
	+$(selfMake) $(@:maps/%=maps/.%.last_cleanup)
243
endif
244
245 1530 aaronmk
maps/VegBIEN.%.csv: maps/$(via).%.full.csv $(coreMap)
246
	$(bin)/join <$+|$(bin)/sort_map >$@
247
maps += $(autogenMaps)
248
249 1789 aaronmk
maps: $(createOnlyMaps) $(maps) _always ;
250 1139 aaronmk
251
all += $(maps)
252
253 1742 aaronmk
##### Maps validation
254
255
missing_mappings: _always missing_join_mappings missing_input_mappings ;
256
257
missing_%_mappings: _always # stem is one of join|input
258
	@echo $(emph)"Missing $* mappings:"$(endEmph)
259
	@+$(selfMake) remake 2>&1\
260 1800 aaronmk
|$(SED) -n 's/^.*No.* $* mapping for ([0-9A-Za-z_-]+).*$$/\1/p'\
261 1742 aaronmk
$(if $(filter join,$*),|$(bin)/ucase_first 0)|sort|uniq
262
263 1509 aaronmk
##### External dependencies
264
265
$(root)/%: _always
266
	+$(subMake)
267 1628 aaronmk
.PRECIOUS: $(root)/% # let ext. dir's Makefile decide whether to delete on error
268 1509 aaronmk
269 783 aaronmk
##### Mapping
270 368 aaronmk
271 775 aaronmk
+maps = $(filter maps/% $(mappings)/%,$(+_))
272 1451 aaronmk
<in = $(firstword $(filter-out $(+maps),$(+_)))
273
map = $(if $(<in),<$(<in),\
274 1777 aaronmk
$(if $(srcs),$(withCatSrcs),\
275 1451 aaronmk
$(if $(mapEnv),env $(mapEnv),\
276 3387 aaronmk
$(error No input file src/*.$*.{$(exts)}))))\
277 1451 aaronmk
$(root)/map $(+maps)
278 3387 aaronmk
map2db = $(if $(use_staged),env in_database=vegbien in_schema=$(datasrc)\
279
in_table=$*) env out_database=vegbien $(map)
280 368 aaronmk
281 783 aaronmk
##### Import to VegBIEN
282 772 aaronmk
283 1378 aaronmk
ifneq ($(dbExport)$(inputFiles),)
284 772 aaronmk
285 1853 aaronmk
profileTest = $(if $(profile),$(if $(test),1))
286
profileOnly = -env profile_to=/dev/fd/3 $(map2db) 3>&1 1>&2|\
287
$(bin)/profile_stats /dev/fd/0
288
289 3317 aaronmk
log_ = import/$*$(if $(n),.n=$(n),).$(date).log.sql
290
trace = $(log_:.log.sql=.trace)
291 1853 aaronmk
import = -$(if $(profileTest),$(profileOnly),(set -x; "time" env commit=1\
292 1190 aaronmk
$(if $(profile),profile_to=$(trace)) $(map2db)) $(if $(log),\
293 3382 aaronmk
$(if $(n),,&>>$(log_)))$(if $(log),$(if $(n), 2>&1|tee -a $(log_))))
294 1088 aaronmk
# don't abort on import errors, which often relate to invalid input data
295 624 aaronmk
296 1193 aaronmk
import: $(addprefix import-,$(tables)) _always ;
297 718 aaronmk
298
import-%: maps/VegBIEN.%.csv _always
299
	$(import)
300 772 aaronmk
# default:
301
import-%: _always ;
302 718 aaronmk
303 772 aaronmk
else
304
import: _always ;
305
endif
306
307 790 aaronmk
##### Log files from import
308
309 3317 aaronmk
logs := $(wildcard import/*.log.sql import/*.trace)
310 339 aaronmk
311 383 aaronmk
rm_logs: _always
312 339 aaronmk
	$(RM) $(logs)
313
314 783 aaronmk
##### Verification of import
315 264 aaronmk
316 1194 aaronmk
verify: $(addprefix verify-,$(tables)) _always ;
317
318 1199 aaronmk
verify-%: verify/%.ref verify/%.out _always
319 1184 aaronmk
	-$(diffVerbose) $(+_)
320 1088 aaronmk
# don't abort on verification errors, which are expected during development
321 1194 aaronmk
# default:
322 1199 aaronmk
verify-%: verify/%.out _always
323 1200 aaronmk
	$(if $(shell test -e $< && echo t),cat $<)
324 1199 aaronmk
# don't run if verify/%.out's default do-nothing action was used
325 1200 aaronmk
# can't use $(wildcard) because it won't recheck file after verify/%.out is run
326 368 aaronmk
327 1620 aaronmk
verify = $(if $(reverify),"time" $(psqlAsBien) --set=datasource="'$(datasrc)'"\
328
--no-align --field-separator=$$'\t' --pset=footer=off --pset=null=NULL <$< >$@)
329 514 aaronmk
330 1199 aaronmk
verify/%.out: $(mappings)/verify.%.sql _always
331 1192 aaronmk
	$(verify)
332 1194 aaronmk
# default:
333 1199 aaronmk
verify/%.out: _always ;
334 369 aaronmk
335 1199 aaronmk
all += $(wildcard verify/*.out)
336 1192 aaronmk
337 1378 aaronmk
ifneq ($(dbExport),)
338 1082 aaronmk
%.ref: %.ref.sql
339
	$(dbAsBien) $(db) <$< >$@
340
endif
341
342 1667 aaronmk
##### Editing import
343
344
import/rotate: _always
345 1668 aaronmk
	echo "UPDATE party SET organizationname = organizationname||'.$(date)'\
346 1854 aaronmk
WHERE organizationname = '$(datasrc)';"|$(psqlAsBien)
347 1667 aaronmk
348
import/rm: _always
349 1854 aaronmk
	echo "DELETE FROM party WHERE organizationname = '$(datasrc)';"|\
350
$(psqlAsBien)
351 1667 aaronmk
352 783 aaronmk
##### Testing
353 368 aaronmk
354 1986 aaronmk
testRefOutput = $(subst .2-step,,$(subst .staging,,$(1)))
355
testRef = $(testRefOutput).ref
356
hasOwnRef = $(filter $@,$(call testRefOutput,$@))
357
# filter returns non-empty if they are equal
358 630 aaronmk
359 897 aaronmk
define runTest
360 776 aaronmk
@echo "Testing $(abspath $@)..."
361 991 aaronmk
>$@ env test=1 n=$(test_n) $(1)
362 1184 aaronmk
@(set -x; $(diff) $(call testRef,$@) $@) 2>&1 || { e=$$?;\
363 780 aaronmk
$(if $(wildcard $(call testRef,$@)),,cat $@;)\
364 777 aaronmk
$(if $(hasOwnRef),\
365 3179 aaronmk
{\
366
read -p $(emph)'Accept new test output? (y/n)'$(endEmph) REPLY;\
367
if test "$$REPLY" = y; then\
368
(set -x; $(MAKE) $@-ok --directory=$(realpath .) --makefile=../input.Makefile);\
369
exit 0;\
370
fi;\
371
};,\
372 777 aaronmk
echo $(emph)"Note: The preceding failed test is compared to another test's\
373
output"$(endEmph);\
374
echo $(emph)"When it fails, this always indicates a bug"$(endEmph);\
375
)\
376 652 aaronmk
exit $$e;}
377 628 aaronmk
endef
378
379 897 aaronmk
test2File = $(call runTest,$(map))
380 1986 aaronmk
test2Db = $(call runTest,$(map2db))
381 775 aaronmk
382 876 aaronmk
tests :=
383
384 1139 aaronmk
test/$(via).%.xml: maps/$(via).%.full.csv _always
385 775 aaronmk
	$(test2File)
386 876 aaronmk
tests += test/$(via).%.xml
387 629 aaronmk
388 876 aaronmk
test/VegBIEN.%.xml: maps/VegBIEN.%.csv _always
389 775 aaronmk
	$(test2File)
390 876 aaronmk
tests += test/VegBIEN.%.xml
391 628 aaronmk
392 884 aaronmk
test/VegBIEN.%.2-step.xml: test/$(via).%.xml $(coreMap) _always
393 775 aaronmk
	-$(test2File)
394 722 aaronmk
# Don't abort tester if only 2-step test fails, as it's often finicky
395 876 aaronmk
tests += test/VegBIEN.%.2-step.xml
396 630 aaronmk
397 876 aaronmk
test/import.%.out: maps/VegBIEN.%.csv _always
398 1986 aaronmk
	$(test2Db)
399 876 aaronmk
tests += test/import.%.out
400 627 aaronmk
401 1987 aaronmk
testStaged2Db = $(foreach use_staged,1,$(test2Db))
402
    # run with use_staged=1
403 1986 aaronmk
404
# Requires staging tables. To create them, run `make inputs/<datasrc>/install`.
405
test/import.%.staging.out: maps/VegBIEN.%.csv _always
406 1988 aaronmk
	-$(if $(isCsv),$(testStaged2Db),cp -p $(@:.staging.out=.out) $@)
407
# Don't abort tester if only staging test fails, in case staging table missing
408
# Non-flat-file inputs fall back to mimicking a successful test
409 1986 aaronmk
tests += test/import.%.staging.out
410
411 876 aaronmk
testOutputs := $(foreach test,$(tests),$(tables:%=$(test)))
412 724 aaronmk
413 1361 aaronmk
.PRECIOUS: $(testOutputs) # save outputs of failed tests so they can be accepted
414
415 876 aaronmk
test: _always $(testOutputs) ;
416
417 1987 aaronmk
all += $(filter-out %.ref,$(wildcard test/*))
418 876 aaronmk
419 634 aaronmk
# Accepts a test output: make <test_output_path>-ok
420 626 aaronmk
%-ok: _always
421 630 aaronmk
	$(CP) $* $(call testRef,$*)
422 502 aaronmk
423 3579 aaronmk
test/accept-all: _always
424
	+yes|$(selfMake) test
425
426 3133 aaronmk
##### Documentation
427
428 3590 aaronmk
steps = $(selfMake) -s import test=1 by_col=1 verbosity=2 n=100\
429 3385 aaronmk
2>&1|$(bin)/debug2redmine >$@
430 3188 aaronmk
431 3133 aaronmk
import/steps.by_col.sql: _always
432 3188 aaronmk
	+$(steps)
433 3133 aaronmk
434 783 aaronmk
##### Input-type-specific
435 368 aaronmk
436 1917 aaronmk
# Each input type needs var $(mapEnv) and targets src/install, src/uninstall
437 624 aaronmk
438 1379 aaronmk
#### DB export
439
440 1378 aaronmk
ifneq ($(dbExport),)
441 256 aaronmk
442 1378 aaronmk
dbEngineExt := $(subst .,,$(suffix $(basename $(notdir $(dbExport)))))
443 1196 aaronmk
db := $(datasrc)
444 622 aaronmk
445 1379 aaronmk
### Installation
446 256 aaronmk
447 1917 aaronmk
src/install: _always db ;
448 339 aaronmk
449 1917 aaronmk
src/uninstall: _always rm_db ;
450 368 aaronmk
451 1379 aaronmk
### DB-engine-specific
452 621 aaronmk
453 624 aaronmk
# Each DB engine needs vars $(dbEngine), $(dbAsBien) and targets db, rm_db
454 256 aaronmk
455 622 aaronmk
ifeq ($(dbEngineExt),my)
456 621 aaronmk
457 622 aaronmk
dbEngine := MySQL
458
459 621 aaronmk
bienPassword := $(shell cat $(root)/config/bien_password)
460
mysqlAs = mysql --user=$(1) --password='$(bienPassword)'
461
mysqlAsRoot := $(call mysqlAs,root)
462
dbAsBien := $(call mysqlAs,bien)
463
464 1097 aaronmk
dbExists = $(shell echo "SHOW DATABASES LIKE '$(db)';"|$(mysqlAsRoot))
465
466
define createDb
467 1098 aaronmk
echo "CREATE DATABASE $(db) DEFAULT CHARACTER SET latin1;"|$(mysqlAsRoot)
468 1097 aaronmk
-$(mysqlAsRoot) --database=$(db) <$<
469
endef
470
# ignore errors in db import so that GRANT will still be run
471
472 1378 aaronmk
db: $(dbExport) _always
473 1097 aaronmk
	$(if $(dbExists),,$(createDb))
474 368 aaronmk
	echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysqlAsRoot)
475 250 aaronmk
476 383 aaronmk
rm_db: _always
477 368 aaronmk
	-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysqlAsRoot)
478
	echo "DROP DATABASE IF EXISTS $(db);"|$(mysqlAsRoot)
479 365 aaronmk
# ignore errors if grant not defined
480 250 aaronmk
481 1379 aaronmk
## Unrecognized DB engine
482 368 aaronmk
483
else
484 1378 aaronmk
$(error The DB filename $(dbExport) must be db.my.sql)
485 368 aaronmk
endif
486
487 1379 aaronmk
### Other input types
488 622 aaronmk
489 1379 aaronmk
else
490 624 aaronmk
491 1917 aaronmk
src/install: _always ;
492
src/uninstall: _always ;
493 1379 aaronmk
494 256 aaronmk
endif
495 1379 aaronmk
496
#### DB connection info
497
498
ifneq ($(dbEngine),)
499
# Must come after dbEngine is set
500
mapEnv := in_engine=$(dbEngine) in_database=$(db)
501
endif