1 |
256
|
aaronmk
|
selfDir_3d1bc249 := $(dir $(lastword $(MAKEFILE_LIST)))
|
2 |
250
|
aaronmk
|
|
3 |
|
|
mysql := mysql --user=root --password='$(shell cat \
|
4 |
256
|
aaronmk
|
$(selfDir_3d1bc249)/bien_password)'
|
5 |
247
|
aaronmk
|
|
6 |
250
|
aaronmk
|
#####
|
7 |
|
|
|
8 |
256
|
aaronmk
|
all: _not_file # empty rule since must be first target in file
|
9 |
247
|
aaronmk
|
|
10 |
|
|
.SUFFIXES:
|
11 |
|
|
|
12 |
|
|
_not_file:
|
13 |
|
|
.PHONY: _not_file
|
14 |
250
|
aaronmk
|
|
15 |
256
|
aaronmk
|
all =
|
16 |
|
|
|
17 |
|
|
clean: _not_file
|
18 |
|
|
$(RM) $(all)
|
19 |
|
|
|
20 |
250
|
aaronmk
|
#####
|
21 |
|
|
|
22 |
256
|
aaronmk
|
ifdef db
|
23 |
|
|
|
24 |
260
|
aaronmk
|
ifndef dbEngine
|
25 |
|
|
$(error dbEngine variable must be set. Possible values: MySQL, PostgreSQL)
|
26 |
|
|
endif
|
27 |
|
|
|
28 |
256
|
aaronmk
|
all = db.sh
|
29 |
|
|
|
30 |
|
|
all: _not_file $(all)
|
31 |
|
|
|
32 |
|
|
db.sh:
|
33 |
|
|
echo 'engine=$(dbEngine) database=$(db)' >$@
|
34 |
|
|
|
35 |
|
|
###
|
36 |
|
|
|
37 |
|
|
install: _not_file all db
|
38 |
|
|
|
39 |
|
|
uninstall: _not_file rm_db clean
|
40 |
|
|
|
41 |
|
|
db: $(db).sql _not_file
|
42 |
255
|
aaronmk
|
-$(mysql) <$<
|
43 |
|
|
echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysql)
|
44 |
|
|
# ignore errors in db import so that GRANT will still be run
|
45 |
250
|
aaronmk
|
|
46 |
256
|
aaronmk
|
rm_db: _not_file
|
47 |
255
|
aaronmk
|
-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysql)
|
48 |
250
|
aaronmk
|
echo "DROP DATABASE IF EXISTS $(db);"|$(mysql)
|
49 |
255
|
aaronmk
|
# ignore errors about no such grant being defined
|
50 |
250
|
aaronmk
|
|
51 |
256
|
aaronmk
|
#####
|
52 |
|
|
|
53 |
|
|
else
|
54 |
|
|
$(error db variable must be set)
|
55 |
|
|
endif
|
56 |
|
|
|
57 |
250
|
aaronmk
|
reinstall: _not_file uninstall install
|