1 # $Id: Makefile,v 1.6 2004-09-06 08:21:35 rurban Exp $
2 # user-definable settings:
7 DB_SQLITE_DBFILE = /tmp/phpwiki-sqlite.db
9 # ****************************************************************************
10 # get db params from config/config.ini
13 DATABASE_TYPE := $(shell config/make-dbhelper.pl -v=DATABASE_TYPE config/config.ini)
15 ifeq (${DATABASE_TYPE},SQL)
18 ifeq (${DATABASE_TYPE},ADODB)
23 ifeq (${PROCESS_DSN},1)
24 # get db params from config/config.ini DATABASE_DSN setting (only if SQL or ADODB)
25 DATABASE_DSN := $(shell config/make-dbhelper.pl -v=DATABASE_DSN config/config.ini)
27 DB_DBTYPE := $(word 1,${DATABASE_DSN})
29 DB_DB := $(word 2,${DATABASE_DSN})
31 DB_USER := $(word 3,${DATABASE_DSN})
33 DB_PASS := $(word 4,${DATABASE_DSN})
34 #Todo: read optional DBADMIN_USER and DBADMIN_PASS settings from config.ini
35 DBADMIN_OPTS=-u$(DBADMIN_USER) -p$(DBADMIN_PASS)
37 DB_DBTYPE=${DATABASE_TYPE}
40 # ****************************************************************************
41 PHP_SRC := $(wildcard *.php ./lib/*.php ./lib/WikiDB/*.php ./lib/plugin/*.php)
43 .PHONY: all install locale mysql pqsql sqlite dbtest
49 if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
50 /usr/bin/find . \( -type d -regex '\(^\./lib/pear\)\|\(^\./lib/WikiDB/adodb\)\|\(^\./lib/nusoap\)\|\(^\./lib/fpdf\)\|\(^\./locale/.*/LC_MESSAGES\)' \) -prune -o -name \*.php | etags -
53 if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
55 # /usr/bin/find . -name \*.php -o -name \*.tmpl | etags -L - --langmap="HTML:.tmpl" -f $@
56 /usr/bin/find . -name \*.php -o -name \*.tmpl | etags - -o $@
62 install: install-config install-database
64 install-config: config/config.ini
66 config/config.ini: config/config-dist.ini
67 cp config/config-dist.ini $@
68 echo "You must edit config/config.ini, at least set the ADMIN_PASSWD"
71 # helpers for database installation
72 install-database: ${DB_DBTYPE}
78 # maybe setup permissions
82 echo DATABASE_TYPE=${DATABASE_TYPE} DB_DBTYPE=${DB_DBTYPE} DB_DB=$(DB_DB) DB_USER=${DB_USER} DB_PASS=${DB_PASS} DBADMIN_OPTS=$(DBADMIN_OPTS)
84 # initialize the database
85 # TODO: compare /var/mysql/data/$(DB_DB) timestamp against schemas/mysql.sql
87 mysqladmin $(DB_OPTS) create $(DB_DB)
88 mysql $(DB_OPTS) -e "GRANT select,insert,update,delete,lock tables ON $(DB_DB).* \
89 TO $(DB_USER)@localhost IDENTIFIED BY '$(DB_PASS)';"
90 mysql $(DB_OPTS) $(DB_DB) < schemas/mysql-initialize.sql
92 # initialize the database
97 createuser -D -A -P $(DB_USER)
99 createuser -D -A $(DB_USER)
101 psql $(DB_DB) -f schemas/psql-initialize.sql
104 # initialize the database
105 sqlite: $(DB_SQLITE_DBFILE)
106 sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite-initialize.sql
108 # update the database
109 ${DB_SQLITE_DBFILE}: schemas/sqlite.sql
110 echo ".dump" | sqlite ${DB_SQLITE_DBFILE} > dump.sql
111 mv ${DB_SQLITE_DBFILE} ${DB_SQLITE_DBFILE}.old
112 sqlite $(DB_SQLITE_DBFILE) < dump.sql