1 # $Id: Makefile,v 1.11 2005-10-31 17:03:57 rurban Exp $
2 # user-definable settings:
7 # etags (GNU Emacs 21.5.x)
8 ETAGS_STDIN = /usr/bin/etags -L -
9 # etags (GNU Emacs 21.4.15)
10 #ETAGS_STDIN = /usr/bin/etags -
12 DB_SQLITE_DBFILE = /tmp/phpwiki-sqlite.db
14 # ****************************************************************************
15 # get db params from config/config.ini
18 DATABASE_TYPE := $(shell config/make-dbhelper.pl -v=DATABASE_TYPE config/config.ini)
20 ifeq (${DATABASE_TYPE},SQL)
23 ifeq (${DATABASE_TYPE},ADODB)
28 ifeq (${PROCESS_DSN},1)
29 # get db params from config/config.ini DATABASE_DSN setting (only if SQL or ADODB)
30 DATABASE_DSN := $(shell config/make-dbhelper.pl -v=DATABASE_DSN config/config.ini)
32 DB_DBTYPE := $(word 1,${DATABASE_DSN})
34 DB_DB := $(word 2,${DATABASE_DSN})
36 DB_USER := $(word 3,${DATABASE_DSN})
38 DB_PASS := $(word 4,${DATABASE_DSN})
39 #Todo: read optional DBADMIN_USER and DBADMIN_PASS settings from config.ini
40 DBADMIN_OPTS=-u$(DBADMIN_USER) -p$(DBADMIN_PASS)
42 DB_DBTYPE=${DATABASE_TYPE}
45 # ****************************************************************************
46 PHP_SRC := $(wildcard *.php ./lib/*.php ./lib/WikiDB/*.php ./lib/plugin/*.php)
48 .PHONY: all install locale mysql pqsql sqlite dbtest install-config
53 if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
55 /usr/bin/find . \( -type d -regex '\(^\./lib/pear\)\|\(^\./lib/WikiDB/adodb\)\|\(^\./lib/nusoap\)\|\(^\./lib/fpdf\)\|\(^\./locale/.*/LC_MESSAGES\)' \) -prune -o -type f -name \*.php | grep .php | $(ETAGS_STDIN)
58 if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
59 /usr/bin/find . -name \*.php -o -name \*.tmpl | $(ETAGS_STDIN) --langmap="HTML:.tmpl" -f $@
60 # older etags needed this:
61 # /usr/bin/find . -type f -name \*.php -o -name \*.tmpl | etags - -o $@
67 install: install-config install-database
69 install-config: config/config.ini
71 config/config.ini: config/config-dist.ini
72 cp config/config-dist.ini $@
73 echo "You must edit config/config.ini, at least set the ADMIN_PASSWD"
76 # helpers for database installation
77 install-database: ${DB_DBTYPE}
83 # maybe setup permissions
87 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)
89 # initialize the database
90 # TODO: compare /var/mysql/data/$(DB_DB) timestamp against schemas/mysql.sql
92 mysqladmin $(DB_OPTS) create $(DB_DB)
93 mysql $(DB_OPTS) -e "GRANT select,insert,update,delete,lock tables ON $(DB_DB).* \
94 TO $(DB_USER)@localhost IDENTIFIED BY '$(DB_PASS)';"
95 mysql $(DB_OPTS) $(DB_DB) < schemas/mysql-initialize.sql
97 # initialize the database
102 createuser -D -A -P $(DB_USER)
104 createuser -D -A $(DB_USER)
106 psql $(DB_DB) -f schemas/psql-initialize.sql
109 # initialize the database
110 sqlite: $(DB_SQLITE_DBFILE)
111 sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite-initialize.sql
113 # update the database
114 ${DB_SQLITE_DBFILE}: schemas/sqlite.sql
115 echo ".dump" | sqlite ${DB_SQLITE_DBFILE} > dump.sql
116 mv ${DB_SQLITE_DBFILE} ${DB_SQLITE_DBFILE}.old
117 sqlite $(DB_SQLITE_DBFILE) < dump.sql