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
ifndef dbEngine
25
$(error dbEngine variable must be set. Possible values: MySQL, PostgreSQL)
26
endif
27

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

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

    
51
#####
52

    
53
else
54
$(error db variable must be set)
55
endif
56

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