Project

General

Profile

1
selfDir_3d1bc249 := $(dir $(lastword $(MAKEFILE_LIST)))
2

    
3
mysql := mysql --user=root --password='$(shell cat \
4
$(selfDir_3d1bc249)/bien_password)'
5

    
6
#####
7

    
8
all: _not_file # empty rule since must be first target in file
9

    
10
.SUFFIXES:
11

    
12
_not_file:
13
.PHONY: _not_file
14

    
15
all =
16

    
17
clean: _not_file
18
	$(RM) $(all)
19

    
20
#####
21

    
22
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
	-$(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

    
44
rm_db: _not_file
45
	-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysql)
46
	echo "DROP DATABASE IF EXISTS $(db);"|$(mysql)
47
# ignore errors about no such grant being defined
48

    
49
#####
50

    
51
else
52
$(error db variable must be set)
53
endif
54

    
55
reinstall: _not_file uninstall install
(5-5/16)