1 # $Id: Makefile,v 1.13 2007-07-19 06:21:12 rurban Exp $
2 # user-definable settings:
7 # etags (GNU Emacs 21.4.x)
8 ETAGS_21_5=$(shell etags --version|grep "Ctags 5.6")
9 ifeq ("$(ETAGS_21_5)", "")
10 ETAGS_STDIN = /usr/bin/etags -
12 # new etags (GNU Emacs 21.5.x)
13 ETAGS_STDIN = /usr/bin/etags -L -
16 DB_SQLITE_DBFILE = /tmp/phpwiki-sqlite.db
18 # ****************************************************************************
19 # get db params from config/config.ini
22 DATABASE_TYPE := $(shell config/make-dbhelper.pl -v=DATABASE_TYPE config/config.ini)
24 ifeq (${DATABASE_TYPE},SQL)
27 ifeq (${DATABASE_TYPE},ADODB)
32 ifeq (${PROCESS_DSN},1)
33 # get db params from config/config.ini DATABASE_DSN setting (only if SQL or ADODB)
34 DATABASE_DSN := $(shell config/make-dbhelper.pl -v=DATABASE_DSN config/config.ini)
36 DB_DBTYPE := $(word 1,${DATABASE_DSN})
38 DB_DB := $(word 2,${DATABASE_DSN})
40 DB_USER := $(word 3,${DATABASE_DSN})
42 DB_PASS := $(word 4,${DATABASE_DSN})
43 #Todo: read optional DBADMIN_USER and DBADMIN_PASS settings from config.ini
44 DBADMIN_OPTS=-u$(DBADMIN_USER) -p$(DBADMIN_PASS)
46 DB_DBTYPE=${DATABASE_TYPE}
49 # ****************************************************************************
50 PHP_SRC := $(wildcard *.php ./lib/*.php ./lib/WikiDB/*.php ./lib/plugin/*.php)
52 .PHONY: all install locale mysql pqsql sqlite dbtest install-config
57 if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
59 /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)
62 if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
63 /usr/bin/find . -name \*.php -o -name \*.tmpl | $(ETAGS_STDIN) --langmap="HTML:.tmpl" -f $@
64 # older etags needed this:
65 # /usr/bin/find . -type f -name \*.php -o -name \*.tmpl | etags - -o $@
71 install: install-config install-database
73 install-config: config/config.ini
75 config/config.ini: config/config-dist.ini
76 cp config/config-dist.ini $@
77 echo "You must edit config/config.ini, at least set the ADMIN_PASSWD"
80 # helpers for database installation
81 install-database: ${DB_DBTYPE}
87 # maybe setup permissions
91 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)
93 # initialize the database
94 # TODO: compare /var/mysql/data/$(DB_DB) timestamp against schemas/mysql.sql
96 mysqladmin $(DB_OPTS) create $(DB_DB)
97 mysql $(DB_OPTS) -e "GRANT select,insert,update,delete,lock tables ON $(DB_DB).* \
98 TO $(DB_USER)@localhost IDENTIFIED BY '$(DB_PASS)';"
99 mysql $(DB_OPTS) $(DB_DB) < schemas/mysql-initialize.sql
101 # initialize the database
106 createuser -D -A -P $(DB_USER)
108 createuser -D -A $(DB_USER)
110 psql $(DB_DB) -f schemas/psql-initialize.sql
113 # initialize the database
114 sqlite: $(DB_SQLITE_DBFILE)
115 sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite-initialize.sql
117 # update the database
118 ${DB_SQLITE_DBFILE}: schemas/sqlite.sql
119 echo ".dump" | sqlite ${DB_SQLITE_DBFILE} > dump.sql
120 mv ${DB_SQLITE_DBFILE} ${DB_SQLITE_DBFILE}.old
121 sqlite $(DB_SQLITE_DBFILE) < dump.sql