Project

General

Profile

« Previous | Next » 

Revision 235

scripts/Makefile: Added dependency installation. Makefiles: Use _not_file instead of FORCE for clarity. Use $(os) var

View differences:

Makefile
1
esc = $$'\x1B['
2
reset = $(esc)'0m'
3
highlight = $(esc)'7m'
4

  
5
os = $(shell uname)
6
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1))
7

  
1 8
export PGOPTIONS = --client-min-messages=WARNING
2 9

  
3 10
psqlOpts = --set ON_ERROR_STOP=1 --quiet
......
6 13
psqlDbUser = ./util/psql_vegbien $(psqlOpts)
7 14

  
8 15

  
9
all: FORCE install
16
all: _not_file install
10 17

  
11 18
.SUFFIXES:
12 19

  
13
FORCE:
14
.PHONY: FORCE
20
_not_file:
21
.PHONY: _not_file
15 22

  
16 23

  
17
install: FORCE user db
24
install: _not_file deps user db
18 25

  
19
uninstall: FORCE rm_db rm_user
26
uninstall: _not_file rm_db rm_user
20 27

  
21
reinstall: FORCE uninstall install
28
reinstall: _not_file uninstall install
22 29

  
23
reinstall_db: FORCE rm_db db
24 30

  
25
empty_db: FORCE
31
deps: _not_file $(call forOs,postgres mysql)
32

  
33
postgres-Linux: _not_file
34
	sudo apt-get install python-dev python-pip libpq-dev
35
	sudo pip install psycopg2
36

  
37
postgres-Darwin: _not_file
38

  
39
mysql-Linux: _not_file
40
	sudo apt-get install mysql-server mysql-client python-mysqldb
41

  
42
mysql-Darwin: _not_file
43
	@echo $(highlight)'Installing MySQLdb Python driver on Mac OS X 10.7 (may work on other versions):'$(reset)
44
	@echo 'Download it using "latest version" link at http://sourceforge.net/projects/mysql-python/files/'
45
	@echo 'Extract the archive'
46
	@echo '(From http://www.rustyrazorblade.com/2011/11/installing-mysqldb-on-macos-lion/:)'
47
	@echo 'Run sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib'
48
	@echo 'Run sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql'
49
	@echo '(From http://blog.infoentropy.com/MySQL-python_EnvironmentError_mysql_config_not_found:)'
50
	@echo 'Edit site.cfg and change the line like "mysql_config = " to "mysql_config = /usr/local/mysql/bin/mysql_config"'
51
	@echo '(From http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/:)'
52
	@echo 'Change to the directory of the extracted files'
53
	@echo 'Run sudo python setup.py clean'
54
	@echo 'Run sudo python setup.py build'
55
	@echo 'Run sudo python setup.py install'
56
	@echo "Run python -c 'import MySQLdb'"
57
	@read -p $(highlight)'Press ENTER to continue:'$(reset)
58

  
59
# Catch-alls for other OSes
60
mysql-:
61
postgres-:
62

  
63
reinstall_db: _not_file rm_db db
64

  
65
empty_db: _not_file
26 66
	$(psqlDbUser) <../mappings/schemas/vegbien_empty.sql
27 67

  
28
user: FORCE
68
user: _not_file
29 69
	$(MAKE) _$@
30 70

  
31 71
ifeq ($(MAKECMDGOALS),_user)
32 72
include util/vegbien_dest
33 73
endif
34 74

  
35
_user: FORCE
36
	@echo "At sudo password prompt, enter *your* password"
75
_user: _not_file
76
	@echo $(highlight)"At sudo password prompt, enter *your* password"$(reset)
37 77
	@sudo -v
38
	@echo "At prompt \"Enter password for new role:\", enter $(out_password)"
78
	@echo $(highlight)"At prompt \"Enter password for new role:\", enter $(out_password)"$(reset)
39 79
	-$(_user_cmd)
40 80
# ignore errors about existing user
41 81
_user_cmd = $(asAdmin) createuser --no-superuser --no-createdb --no-createrole \
42 82
--pwprompt "$(out_user)"
43 83

  
44
rm_user: FORCE
84
rm_user: _not_file
45 85
	echo "DROP USER bien;"|$(psqlAdmin)
46 86

  
47
db: FORCE
87
db: _not_file
48 88
	$(psqlAdmin) <../mappings/schemas/vegbien.sql
49 89

  
50
rm_db: FORCE
90
rm_db: _not_file
51 91
	echo "DROP DATABASE vegbien;"|$(psqlAdmin)
52 92

  
53 93

  
54 94
test: test-map
55 95

  
56
test-%: FORCE
96
test-%: _not_file
57 97
	./test/$(*F)

Also available in: Unified diff