]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - Makefile
get db params from config/config.ini
[SourceForge/phpwiki.git] / Makefile
1 # gnu make (also with cygwin) version
2 DB_ADMINUSER=root
3 DB_ADMINPASS=secret
4 # get db params from config/config.ini
5 DATABASE_DSN := $(shell config/make-dbhelper.pl config/config.ini)
6 #DB_DB=phpwiki
7 DB_DB   := $(word 1,${DATABASE_DSN})
8 #DB_USER=wikiuser
9 DB_USER := $(word 2,${DATABASE_DSN})
10 #DB_PASS=
11 DB_PASS := $(word 3,${DATABASE_DSN})
12
13
14 DB_SQLITE_DBFILE = /tmp/phpwiki-sqlite.db
15 # ****************************************************************************
16 PHP_SRC := $(wildcard *.php ./lib/*.php ./lib/WikiDB/*.php ./lib/plugin/*.php)
17
18 .PHONY: all locale mysql psql sqlite
19
20 all:  TAGS
21
22 TAGS:  $(PHP_SRC)
23 #       etags $(PHP_SRC)
24         if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
25         /usr/bin/find . \( -type d -regex '\(^\./lib/pear\)\|\(^\./lib/WikiDB/adodb\)\|\(^\./lib/nusoap\)\|\(^\./lib/fpdf\)\|\(^\./locale/.*/LC_MESSAGES\)' \) -prune -o -name \*.php | etags -L -
26
27 TAGS.full:  $(PHP_SRC)
28         if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
29         /usr/bin/find . -name \*.php -o -name \*.tmpl | etags -L - --langmap="HTML:.tmpl" -f $@;
30
31 locale: 
32         cd locale
33         make
34
35 DB_OPTS=-u$(DB_ADMINUSER) -p$(DB_ADMINPASS)
36
37 dbtest:
38         echo DB_OPTS=$(DB_OPTS) DB_DB=$(DB_DB) DB_USER=${DB_USER} DB_PASS=${DB_PASS}
39
40 # initialize the database
41 mysql:
42         mysqladmin $(DB_OPTS) create $(DB_DB)
43         mysql $(DB_OPTS) -e "GRANT select,insert,update,delete,lock tables ON $(DB_DB).* \
44 TO $(DB_USER)@localhost IDENTIFIED BY '$(DB_PASS)';"
45         mysql $(DB_OPTS) $(DB_DB) < schemas/mysql.sql
46
47 # initialize the database
48 psql:
49         su postmaster
50         createdb $(DB_DB)
51         ifeq ($(DB_PASS),"")
52           createuser -D -A -P $(DB_USER)
53         else
54           createuser -D -A $(DB_USER)
55         endif
56         psql $(DB_DB) -f schemas/psql.sql
57         logout
58
59 # initialize the database
60 sqlite:
61         sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite.sql
62
63 # update the database
64 ${DB_SQLITE_DBFILE}: schemas/sqlite.sql
65         echo ".dump" | sqlite ${DB_SQLITE_DBFILE} > dump.sql
66         mv ${DB_SQLITE_DBFILE} ${DB_SQLITE_DBFILE}.old
67         sqlite $(DB_SQLITE_DBFILE) < dump.sql