Project

General

Profile

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
all = db.sh
25
26
all: _not_file $(all)
27
28
dbEngine ?= MySQL
29
30
db.sh:
31
	echo 'engine=$(dbEngine) database=$(db)' >$@
32
33
###
34
35
install: _not_file all db
36
37
uninstall: _not_file rm_db clean
38
39
db: $(db).sql _not_file
40 255 aaronmk
	-$(mysql) <$<
41
	echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysql)
42
# ignore errors in db import so that GRANT will still be run
43 250 aaronmk
44 256 aaronmk
rm_db: _not_file
45 255 aaronmk
	-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysql)
46 250 aaronmk
	echo "DROP DATABASE IF EXISTS $(db);"|$(mysql)
47 255 aaronmk
# ignore errors about no such grant being defined
48 250 aaronmk
49 256 aaronmk
#####
50
51
else
52
$(error db variable must be set)
53
endif
54
55 250 aaronmk
reinstall: _not_file uninstall install