1 |
5459
|
aaronmk
|
root := .
|
2 |
3762
|
aaronmk
|
include lib/common.Makefile
|
3 |
|
|
|
4 |
|
|
|
5 |
784
|
aaronmk
|
##### Vars/functions
|
6 |
|
|
|
7 |
244
|
aaronmk
|
# Make
|
8 |
247
|
aaronmk
|
SHELL := /bin/bash
|
9 |
625
|
aaronmk
|
subMake = $(MAKE) $(call subPath,$@) --directory=$(call topDir,$@)
|
10 |
244
|
aaronmk
|
|
11 |
4607
|
aaronmk
|
# Paths
|
12 |
|
|
bin := bin
|
13 |
|
|
|
14 |
241
|
aaronmk
|
# Terminal
|
15 |
247
|
aaronmk
|
esc := '['
|
16 |
|
|
reset := $(esc)'0m'
|
17 |
|
|
emph := $(esc)'7m '
|
18 |
|
|
endEmph := ' '$(reset)
|
19 |
245
|
aaronmk
|
|
20 |
|
|
# User interaction
|
21 |
|
|
|
22 |
1745
|
aaronmk
|
done = echo; echo $(emph)"Finished $@"$(endEmph); echo
|
23 |
245
|
aaronmk
|
|
24 |
247
|
aaronmk
|
wait := read -p $(emph)'Press ENTER to continue:'$(endEmph) REPLY
|
25 |
245
|
aaronmk
|
|
26 |
2090
|
aaronmk
|
confirm = $(if $(shell read -p $(emph)"$(1)"$(endEmph)$$'$(if\
|
27 |
|
|
$(2),\n$(2))\nContinue? (y/n) ' REPLY; test "$$REPLY" = y && echo t),,\
|
28 |
|
|
$(error Aborting))
|
29 |
235
|
aaronmk
|
|
30 |
335
|
aaronmk
|
# File editing
|
31 |
|
|
sudoAppend = echo $$'$(2)'|sudo tee -a $(1) >/dev/null
|
32 |
|
|
|
33 |
2091
|
aaronmk
|
# DB
|
34 |
|
|
mkSchemaCmd = 'CREATE SCHEMA $(1);'
|
35 |
3380
|
aaronmk
|
rmSchemaCmd = 'DROP SCHEMA IF EXISTS "$(1)" CASCADE;'
|
36 |
2091
|
aaronmk
|
|
37 |
784
|
aaronmk
|
##### Environment
|
38 |
|
|
|
39 |
225
|
aaronmk
|
export PGOPTIONS = --client-min-messages=WARNING
|
40 |
|
|
|
41 |
784
|
aaronmk
|
##### General targets
|
42 |
225
|
aaronmk
|
|
43 |
1274
|
aaronmk
|
remake: _always clean
|
44 |
|
|
$(MAKE)
|
45 |
|
|
# re-run make so that cache of existing files is reset
|
46 |
|
|
|
47 |
1288
|
aaronmk
|
%/remake: _always
|
48 |
|
|
$(MAKE) $(@D)/clean
|
49 |
|
|
$(MAKE) $(@D)/
|
50 |
|
|
# re-run make so that cache of existing files is reset
|
51 |
|
|
|
52 |
1813
|
aaronmk
|
%-remake: _always
|
53 |
|
|
rm -f $*
|
54 |
|
|
$(MAKE) $*
|
55 |
|
|
# re-run make so that cache of existing files is reset
|
56 |
|
|
|
57 |
2981
|
aaronmk
|
%/reinstall: _always %/uninstall %/install ;
|
58 |
|
|
|
59 |
784
|
aaronmk
|
##### Installation
|
60 |
241
|
aaronmk
|
|
61 |
6102
|
aaronmk
|
# public must be installed *after* inputs because some views depend on inputs
|
62 |
|
|
install: _always core mysql inputs/download inputs/install schemas/install test
|
63 |
241
|
aaronmk
|
@$(done)
|
64 |
202
|
aaronmk
|
|
65 |
6200
|
aaronmk
|
uninstall: _always rm_mysql rm_core ;
|
66 |
241
|
aaronmk
|
|
67 |
418
|
aaronmk
|
reinstall: _always uninstall install ;
|
68 |
225
|
aaronmk
|
|
69 |
784
|
aaronmk
|
##### Core: VegBIEN DB and dependencies
|
70 |
202
|
aaronmk
|
|
71 |
1746
|
aaronmk
|
core: _always $(call forOs,python php postgres) db
|
72 |
241
|
aaronmk
|
@$(done)
|
73 |
235
|
aaronmk
|
|
74 |
1746
|
aaronmk
|
rm_core: _always rm_db ;
|
75 |
241
|
aaronmk
|
|
76 |
418
|
aaronmk
|
reinstall_core: _always rm_core core ;
|
77 |
241
|
aaronmk
|
|
78 |
784
|
aaronmk
|
##### Python
|
79 |
|
|
|
80 |
383
|
aaronmk
|
python-Linux: _always
|
81 |
2618
|
aaronmk
|
-sudo apt-get install python
|
82 |
6215
|
aaronmk
|
-sudo apt-get install python3
|
83 |
2618
|
aaronmk
|
-sudo apt-get install python-dev
|
84 |
|
|
-sudo apt-get install python-dateutil
|
85 |
|
|
-sudo apt-get install python-parallel
|
86 |
|
|
-sudo apt-get install python-profiler
|
87 |
|
|
-sudo apt-get install python-pip
|
88 |
|
|
-sudo apt-get install pymetrics
|
89 |
3156
|
aaronmk
|
-sudo pip install ordereddict
|
90 |
1845
|
aaronmk
|
-sudo pip install pp
|
91 |
284
|
aaronmk
|
|
92 |
383
|
aaronmk
|
python-Darwin: _always
|
93 |
6190
|
aaronmk
|
@echo $(emph)'Installing Python 3.2 on Mac OS X:'$(endEmph)
|
94 |
|
|
@echo 'Download it: http://www.python.org/ftp/python/3.2.3/python-3.2.3-macosx10.6.dmg'
|
95 |
|
|
@echo 'Open the disk image'
|
96 |
|
|
@echo 'Run the installer in it'
|
97 |
|
|
@$(wait)
|
98 |
284
|
aaronmk
|
@echo $(emph)'Installing python-dateutil on Mac OS X:'$(endEmph)
|
99 |
|
|
@echo 'Download it: http://labix.org/download/python-dateutil/python-dateutil-1.5.tar.gz'
|
100 |
|
|
@echo 'Extract the archive'
|
101 |
|
|
@echo 'Change to the directory of the extracted files'
|
102 |
|
|
@echo 'Run python setup.py build'
|
103 |
|
|
@echo 'Run sudo python setup.py install'
|
104 |
|
|
@echo "Run python -c 'import dateutil'"
|
105 |
|
|
@$(wait)
|
106 |
3156
|
aaronmk
|
@echo $(emph)'Installing pip on Mac OS X:'$(endEmph)
|
107 |
|
|
@echo 'Follow the instructions at http://www.pip-installer.org/en/latest/installing.html'
|
108 |
|
|
@$(wait)
|
109 |
284
|
aaronmk
|
|
110 |
1599
|
aaronmk
|
##### PHP
|
111 |
|
|
|
112 |
|
|
php-Linux: _always
|
113 |
|
|
-sudo apt-get install php-http-request
|
114 |
|
|
|
115 |
|
|
php-Darwin: _always
|
116 |
1600
|
aaronmk
|
@echo $(emph)'Installing PHP PEAR and HTTP_Request on Mac OS X:'$(endEmph)
|
117 |
|
|
@echo 'Download http://pear.php.net/go-pear.phar'
|
118 |
|
|
@echo 'Change to the directory of the downloaded file'
|
119 |
|
|
@echo 'Run php -d detect_unicode=0 go-pear.phar'
|
120 |
|
|
@echo 'Whenever prompted, press Enter to select default options'
|
121 |
|
|
@echo 'Add $$HOME/pear/bin to your $$PATH'
|
122 |
|
|
@echo 'Add $(HOME)/pear/share/pear to your php.ini include_path'
|
123 |
1665
|
aaronmk
|
@echo 'If needed, set $$PHPRC to your php.ini'
|
124 |
1600
|
aaronmk
|
@echo "Run pear install HTTP_Request"
|
125 |
|
|
@echo 'To run a php command: php -c <php.ini-path> ...'
|
126 |
1599
|
aaronmk
|
@$(wait)
|
127 |
|
|
|
128 |
784
|
aaronmk
|
##### PostgreSQL
|
129 |
|
|
|
130 |
1970
|
aaronmk
|
editPhppgadminApacheConf = echo $$'1\n,s/deny from all/allow from all/\nwq'|\
|
131 |
336
|
aaronmk
|
sudo ed --loose-exit-status --verbose /etc/phppgadmin/apache.conf
|
132 |
334
|
aaronmk
|
|
133 |
|
|
apacheConf := /etc/apache2/apache2.conf
|
134 |
|
|
apacheConfPhppgadminLine := Include /etc/phppgadmin/apache.conf
|
135 |
|
|
editApacheConfForPhppgadmin =\
|
136 |
|
|
$(if $(shell grep -F "$(apacheConfPhppgadminLine)" $(apacheConf)),,\
|
137 |
|
|
$(call sudoAppend,$(apacheConf),\n$(apacheConfPhppgadminLine)))
|
138 |
|
|
|
139 |
335
|
aaronmk
|
nonApacheOnPort80 = $(shell sudo lsof -i :80|tail -n +2|grep -v -F apache2)
|
140 |
336
|
aaronmk
|
editApachePortsConf = echo $$'1\n,s/\\b80\\b/8080/g\nwq'|\
|
141 |
|
|
sudo ed --loose-exit-status --verbose /etc/apache2/ports.conf
|
142 |
334
|
aaronmk
|
|
143 |
6197
|
aaronmk
|
asAdmin := sudo -E -u postgres
|
144 |
6337
|
aaronmk
|
asBien := sudo -E -u bien
|
145 |
4752
|
aaronmk
|
pgVersion = "$$(env minor=1 bin/pg_version)"
|
146 |
|
|
|
147 |
6198
|
aaronmk
|
linuxPostgresDir := /etc/postgresql/9.1/main
|
148 |
6201
|
aaronmk
|
define pg_ctl-Linux
|
149 |
|
|
$(asAdmin) /etc/init.d/postgresql $(1)
|
150 |
|
|
sleep 2
|
151 |
|
|
endef
|
152 |
6198
|
aaronmk
|
|
153 |
6196
|
aaronmk
|
macPostgresDir := /Library/PostgreSQL/9.1
|
154 |
6187
|
aaronmk
|
define macUsePostgresLib
|
155 |
|
|
sudo mv $(libDest) $(libDest).old||sudo rm -f $(libDest)
|
156 |
6196
|
aaronmk
|
sudo ln -s $(macPostgresDir)/lib/$(1) $(libDest)
|
157 |
6187
|
aaronmk
|
|
158 |
|
|
endef
|
159 |
|
|
libDest = /usr/lib/$(1)
|
160 |
|
|
|
161 |
|
|
macPostgresLibs := libcrypto libssl
|
162 |
|
|
macPostgresLibs := $(macPostgresLibs) $(macPostgresLibs:%=%.1.0.0)
|
163 |
|
|
macPostgresLibs := $(macPostgresLibs:%=%.dylib)
|
164 |
|
|
|
165 |
6201
|
aaronmk
|
define pg_ctl-Darwin
|
166 |
|
|
$(asAdmin) pg_ctl -D $(macPostgresDir)/data -l $(macPostgresDir)/postgres.log $(1)
|
167 |
|
|
sleep 2
|
168 |
|
|
endef
|
169 |
6197
|
aaronmk
|
|
170 |
6333
|
aaronmk
|
define postgresReload-Linux
|
171 |
6447
|
aaronmk
|
chmod a+r schemas/*.conf || $(asBien) chmod a+r schemas/*.conf
|
172 |
6473
|
aaronmk
|
mv -n $(linuxPostgresDir)/postgresql.conf $(linuxPostgresDir)/postgresql.conf.old
|
173 |
6333
|
aaronmk
|
$(asAdmin) cp --preserve=timestamps schemas/postgresql.conf $(linuxPostgresDir)/postgresql.conf
|
174 |
6473
|
aaronmk
|
mv -n $(linuxPostgresDir)/pg_hba.conf $(linuxPostgresDir)/pg_hba.conf.old
|
175 |
6335
|
aaronmk
|
$(asAdmin) cp --preserve=timestamps schemas/pg_hba.conf $(linuxPostgresDir)/pg_hba.conf
|
176 |
6333
|
aaronmk
|
$(call pg_ctl-Linux,restart)
|
177 |
|
|
|
178 |
|
|
endef
|
179 |
|
|
|
180 |
|
|
define postgresReload-Darwin
|
181 |
6336
|
aaronmk
|
chmod a+r schemas/*.conf
|
182 |
6473
|
aaronmk
|
$(asAdmin) mv -n $(macPostgresDir)/data/postgresql.conf $(macPostgresDir)/data/postgresql.conf.old
|
183 |
6333
|
aaronmk
|
$(asAdmin) cp schemas/postgresql.Mac.conf $(macPostgresDir)/data/postgresql.conf
|
184 |
6473
|
aaronmk
|
$(asAdmin) mv -n $(macPostgresDir)/data/pg_hba.conf $(macPostgresDir)/data/pg_hba.conf.old
|
185 |
6335
|
aaronmk
|
$(asAdmin) cp schemas/pg_hba.Mac.conf $(macPostgresDir)/data/pg_hba.conf
|
186 |
6333
|
aaronmk
|
$(call pg_ctl-Darwin,restart)
|
187 |
|
|
|
188 |
|
|
endef
|
189 |
|
|
|
190 |
6334
|
aaronmk
|
postgres_reload: _always
|
191 |
|
|
$($(call forOs,postgresReload))
|
192 |
|
|
|
193 |
6333
|
aaronmk
|
postgres-Linux: _always
|
194 |
|
|
-sudo apt-get install postgresql
|
195 |
|
|
-sudo apt-get install postgresql-plpython3-$(pgVersion)
|
196 |
|
|
-sudo apt-get install libpq-dev
|
197 |
|
|
-sudo apt-get install postgresql-$(pgVersion)-postgis
|
198 |
|
|
-sudo apt-get install phppgadmin
|
199 |
|
|
$(editPhppgadminApacheConf)
|
200 |
|
|
$(editApacheConfForPhppgadmin)
|
201 |
|
|
$(if $(nonApacheOnPort80),$(editApachePortsConf))
|
202 |
|
|
-sudo apache2ctl restart
|
203 |
|
|
-sudo pip install psycopg2
|
204 |
|
|
$(postgresReload-Linux)
|
205 |
|
|
# run pg_version inline because it needs postgresql to be installed first
|
206 |
|
|
# ignore errors if conf files already edited
|
207 |
|
|
|
208 |
383
|
aaronmk
|
postgres-Darwin: _always
|
209 |
254
|
aaronmk
|
@echo $(emph)'Installing PostgreSQL on Mac OS X:'$(endEmph)
|
210 |
|
|
@echo 'Download it using the topmost "Mac OS X" link at http://http://www.enterprisedb.com/products-services-training/pgdownload'
|
211 |
|
|
@echo 'Open the disk image'
|
212 |
|
|
@echo 'Run the installer in it'
|
213 |
|
|
@$(wait)
|
214 |
6187
|
aaronmk
|
$(foreach lib,$(macPostgresLibs),$(call macUsePostgresLib,$(lib)))
|
215 |
6333
|
aaronmk
|
$(postgresReload-Darwin)
|
216 |
235
|
aaronmk
|
|
217 |
418
|
aaronmk
|
postgres-: _always ; # other OSes
|
218 |
241
|
aaronmk
|
|
219 |
247
|
aaronmk
|
psqlOpts := --set ON_ERROR_STOP=1 --quiet
|
220 |
6193
|
aaronmk
|
psqlAsAdmin := $(asAdmin) psql $(psqlOpts)
|
221 |
1980
|
aaronmk
|
# -E preserves env vars so PGOPTIONS is passed to psql
|
222 |
2624
|
aaronmk
|
psqlAsAdminVegbien := $(psqlAsAdmin) vegbien
|
223 |
1519
|
aaronmk
|
psqlAsBien := bin/psql_vegbien $(psqlOpts)
|
224 |
272
|
aaronmk
|
bienPassword := $(shell cat config/bien_password)
|
225 |
6331
|
aaronmk
|
bienReadPassword := $(shell cat config/bien_read_password)
|
226 |
241
|
aaronmk
|
|
227 |
784
|
aaronmk
|
##### VegBIEN DB
|
228 |
241
|
aaronmk
|
|
229 |
6331
|
aaronmk
|
#### DB and users
|
230 |
1967
|
aaronmk
|
|
231 |
2090
|
aaronmk
|
confirmRmDb = $(call confirm,WARNING: This will delete your entire VegBIEN\
|
232 |
3374
|
aaronmk
|
DB!,This includes all archived imports and staging tables.)
|
233 |
2089
|
aaronmk
|
|
234 |
2633
|
aaronmk
|
confirmRmPublicSchema = $(call confirm,WARNING: This will delete the current\
|
235 |
|
|
public schema of your VegBIEN DB!,To save it: make schemas/rotate)
|
236 |
2089
|
aaronmk
|
|
237 |
2091
|
aaronmk
|
rmPublicSchema := $(call rmSchemaCmd,public)
|
238 |
1967
|
aaronmk
|
|
239 |
6102
|
aaronmk
|
db: mk_db rm_initial_public _always ;
|
240 |
1967
|
aaronmk
|
|
241 |
|
|
mk_db: _always
|
242 |
1745
|
aaronmk
|
-echo "CREATE USER bien PASSWORD '$(bienPassword)';"|$(psqlAsAdmin)
|
243 |
6331
|
aaronmk
|
-echo "CREATE USER bien_read PASSWORD '$(bienReadPassword)' IN ROLE bien \
|
244 |
|
|
NOINHERIT;"|$(psqlAsAdmin)
|
245 |
2037
|
aaronmk
|
-echo "CREATE DATABASE vegbien WITH OWNER bien TEMPLATE template1 \
|
246 |
1940
|
aaronmk
|
ENCODING 'UTF8' LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';"|$(psqlAsAdmin)
|
247 |
6221
|
aaronmk
|
-echo "CREATE EXTENSION hstore SCHEMA pg_catalog;"|$(psqlAsAdminVegbien)
|
248 |
6189
|
aaronmk
|
-$(asAdmin) createlang plpython3u vegbien
|
249 |
2627
|
aaronmk
|
# ignore errors if user/database/etc. exists
|
250 |
2091
|
aaronmk
|
|
251 |
|
|
rm_initial_public: _always
|
252 |
2089
|
aaronmk
|
@$(confirmRmPublicSchema)
|
253 |
2624
|
aaronmk
|
echo $(rmPublicSchema)|$(psqlAsAdminVegbien)
|
254 |
1967
|
aaronmk
|
# drop public schema *as admin* because it starts out owned by postgres
|
255 |
241
|
aaronmk
|
|
256 |
383
|
aaronmk
|
rm_db: _always
|
257 |
1748
|
aaronmk
|
@$(confirmRmDb)
|
258 |
|
|
echo "DROP DATABASE IF EXISTS vegbien;"|$(psqlAsAdmin)
|
259 |
6331
|
aaronmk
|
echo "DROP USER IF EXISTS bien_read;"|$(psqlAsAdmin)
|
260 |
1748
|
aaronmk
|
echo "DROP USER IF EXISTS bien;"|$(psqlAsAdmin)
|
261 |
241
|
aaronmk
|
|
262 |
418
|
aaronmk
|
reinstall_db: _always rm_db db ;
|
263 |
241
|
aaronmk
|
|
264 |
2631
|
aaronmk
|
#### Schemas
|
265 |
1967
|
aaronmk
|
|
266 |
2980
|
aaronmk
|
schemas := temp functions py_functions public
|
267 |
2631
|
aaronmk
|
schemas/install: $(schemas:%=schemas/%/install) ;
|
268 |
|
|
|
269 |
2980
|
aaronmk
|
schemasReversed := public py_functions functions temp
|
270 |
2631
|
aaronmk
|
schemas/uninstall: $(schemasReversed:%=schemas/%/uninstall) ;
|
271 |
|
|
|
272 |
6098
|
aaronmk
|
psqlNoSearchPath := env no_search_path=1 $(psqlAsBien)
|
273 |
|
|
|
274 |
2631
|
aaronmk
|
### public
|
275 |
|
|
|
276 |
|
|
schemas/public/install: schemas/vegbien.sql _always
|
277 |
6098
|
aaronmk
|
-echo $(call mkSchemaCmd,public)|$(psqlNoSearchPath)
|
278 |
6192
|
aaronmk
|
<$< $(psqlNoSearchPath)
|
279 |
1967
|
aaronmk
|
# ignore errors if schema exists
|
280 |
|
|
# public schema will be owned by bien
|
281 |
6088
|
aaronmk
|
# don't include public in the search_path
|
282 |
1967
|
aaronmk
|
|
283 |
2631
|
aaronmk
|
schemas/public/uninstall: _always
|
284 |
2089
|
aaronmk
|
@$(confirmRmPublicSchema)
|
285 |
6098
|
aaronmk
|
echo $(rmPublicSchema)|$(psqlNoSearchPath)
|
286 |
1967
|
aaronmk
|
|
287 |
5678
|
aaronmk
|
schemas/rename/%: _always
|
288 |
6098
|
aaronmk
|
echo 'ALTER SCHEMA public RENAME TO "$*";'|$(psqlNoSearchPath)
|
289 |
5678
|
aaronmk
|
$(MAKE) schemas/public/install
|
290 |
|
|
|
291 |
5679
|
aaronmk
|
schemas/rotate: _always schemas/rename/public.$(version) ;
|
292 |
2034
|
aaronmk
|
|
293 |
2631
|
aaronmk
|
### py_functions
|
294 |
2091
|
aaronmk
|
|
295 |
2631
|
aaronmk
|
schemas/py_functions/install: schemas/py_functions.sql _always
|
296 |
6098
|
aaronmk
|
-<$< env public= $(psqlAsAdminVegbien)
|
297 |
3376
|
aaronmk
|
# ignore errors if schema exists
|
298 |
2631
|
aaronmk
|
|
299 |
|
|
### Others
|
300 |
|
|
|
301 |
|
|
schemas/%/install: schemas/%.sql _always
|
302 |
6098
|
aaronmk
|
-<$< $(psqlNoSearchPath)
|
303 |
3376
|
aaronmk
|
# ignore errors if schema exists
|
304 |
2091
|
aaronmk
|
|
305 |
3393
|
aaronmk
|
schemas/%/uninstall: _always
|
306 |
6098
|
aaronmk
|
echo $(call rmSchemaCmd,$*)|$(psqlNoSearchPath)
|
307 |
2624
|
aaronmk
|
|
308 |
2983
|
aaronmk
|
# Needed on Ubuntu 12.04 (also other Linuxes?) because %/reinstall is ignored.
|
309 |
|
|
schemas/temp/reinstall: _always schemas/temp/uninstall schemas/temp/install ;
|
310 |
|
|
|
311 |
784
|
aaronmk
|
##### MySQL
|
312 |
241
|
aaronmk
|
|
313 |
383
|
aaronmk
|
mysql: _always $(call forOs,mysql) mysql_user
|
314 |
241
|
aaronmk
|
@$(done)
|
315 |
|
|
|
316 |
418
|
aaronmk
|
rm_mysql: _always rm_mysql_user ;
|
317 |
241
|
aaronmk
|
|
318 |
383
|
aaronmk
|
mysql-Linux: _always
|
319 |
244
|
aaronmk
|
@echo $(emph)"If asked for MySQL root password, enter $(bienPassword)"$(endEmph)
|
320 |
238
|
aaronmk
|
@$(wait)
|
321 |
237
|
aaronmk
|
-sudo apt-get install mysql-server mysql-client python-mysqldb
|
322 |
235
|
aaronmk
|
|
323 |
383
|
aaronmk
|
mysql-Darwin: _always
|
324 |
244
|
aaronmk
|
@echo $(emph)'Installing MySQLdb Python driver on Mac OS X 10.7 (may work on other versions):'$(endEmph)
|
325 |
235
|
aaronmk
|
@echo 'Download it using "latest version" link at http://sourceforge.net/projects/mysql-python/files/'
|
326 |
|
|
@echo 'Extract the archive'
|
327 |
|
|
@echo '(From http://www.rustyrazorblade.com/2011/11/installing-mysqldb-on-macos-lion/:)'
|
328 |
284
|
aaronmk
|
@echo 'Run ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib'
|
329 |
|
|
@echo 'Run ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql'
|
330 |
235
|
aaronmk
|
@echo '(From http://blog.infoentropy.com/MySQL-python_EnvironmentError_mysql_config_not_found:)'
|
331 |
|
|
@echo 'Edit site.cfg and change the line like "mysql_config = " to "mysql_config = /usr/local/mysql/bin/mysql_config"'
|
332 |
|
|
@echo '(From http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/:)'
|
333 |
|
|
@echo 'Change to the directory of the extracted files'
|
334 |
284
|
aaronmk
|
@echo 'Run python setup.py clean'
|
335 |
|
|
@echo 'Run python setup.py build'
|
336 |
235
|
aaronmk
|
@echo 'Run sudo python setup.py install'
|
337 |
|
|
@echo "Run python -c 'import MySQLdb'"
|
338 |
238
|
aaronmk
|
@$(wait)
|
339 |
235
|
aaronmk
|
|
340 |
383
|
aaronmk
|
mysql-: _always # other OSes
|
341 |
235
|
aaronmk
|
|
342 |
247
|
aaronmk
|
mysqlAsRoot := mysql --user=root --password='$(bienPassword)'
|
343 |
235
|
aaronmk
|
|
344 |
383
|
aaronmk
|
mysql_user: _always
|
345 |
241
|
aaronmk
|
-$($@_cmd)
|
346 |
364
|
aaronmk
|
# ignore errors if user exists
|
347 |
244
|
aaronmk
|
mysql_user_cmd = echo "CREATE USER 'bien'@'localhost' IDENTIFIED BY \
|
348 |
245
|
aaronmk
|
'$(bienPassword)';"|$(mysqlAsRoot)
|
349 |
202
|
aaronmk
|
|
350 |
383
|
aaronmk
|
rm_mysql_user: _always
|
351 |
245
|
aaronmk
|
-echo "DROP USER 'bien'@'localhost';"|$(mysqlAsRoot)
|
352 |
364
|
aaronmk
|
# ignore errors if user exists
|
353 |
202
|
aaronmk
|
|
354 |
784
|
aaronmk
|
##### Datasources
|
355 |
202
|
aaronmk
|
|
356 |
418
|
aaronmk
|
inputs: _always inputs/all ;
|
357 |
245
|
aaronmk
|
|
358 |
6191
|
aaronmk
|
inputs/install: _always
|
359 |
6194
|
aaronmk
|
echo '. bin/reinstall_all; wait'|bash -s
|
360 |
6191
|
aaronmk
|
|
361 |
1542
|
aaronmk
|
import: _always import-msg inputs/import ;
|
362 |
|
|
import-msg: _always
|
363 |
1550
|
aaronmk
|
@echo $(emph)"To import all inputs at once:"$(endEmph) . bin/import_all
|
364 |
1542
|
aaronmk
|
@echo
|
365 |
250
|
aaronmk
|
|
366 |
1458
|
aaronmk
|
verify: _always inputs/verify
|
367 |
1241
|
aaronmk
|
@$(done)
|
368 |
386
|
aaronmk
|
|
369 |
1458
|
aaronmk
|
test: _always inputs/test
|
370 |
397
|
aaronmk
|
@$(done)
|
371 |
1458
|
aaronmk
|
|
372 |
|
|
##### Testing
|
373 |
|
|
|
374 |
1743
|
aaronmk
|
test-all: _always remake test missing_mappings
|
375 |
1458
|
aaronmk
|
@$(done)
|
376 |
1967
|
aaronmk
|
|
377 |
|
|
##### Subdir forwarding
|
378 |
|
|
|
379 |
|
|
# Must come last so overridden targets are not forwarded
|
380 |
|
|
|
381 |
|
|
define subdirTargets
|
382 |
|
|
$(subdir): _always
|
383 |
|
|
+$$(subMake)
|
384 |
|
|
|
385 |
|
|
$(subdir)%: _always
|
386 |
|
|
+$$(subMake)
|
387 |
|
|
.PRECIOUS: $(subdir)% # let subdir's Makefile decide whether to delete on error
|
388 |
|
|
|
389 |
|
|
$(subdir)reinstall: _always $(subdir)uninstall $(subdir)install ;
|
390 |
|
|
endef
|
391 |
|
|
$(foreach subdir,$(wildcard */),$(eval $(subdirTargets)))
|
392 |
|
|
|
393 |
|
|
Makefile: ;
|
394 |
|
|
|
395 |
|
|
%: $(addsuffix %,$(dir $(shell echo */Makefile))) _always ;
|
396 |
1999
|
aaronmk
|
|
397 |
|
|
#### Maps validation
|
398 |
|
|
|
399 |
4607
|
aaronmk
|
termsSubdirs := $(call no/,$(call wildcard/,inputs/*/))
|
400 |
|
|
|
401 |
3764
|
aaronmk
|
include lib/mappings.Makefile
|