1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
# $Id: Makefile,v 1.11 2005/10/31 17:03:57 rurban Exp $
# user-definable settings:
# for mysqladmin
DBADMIN_USER=root
DBADMIN_PASS=secret
# etags (GNU Emacs 21.5.x)
#ETAGS_STDIN = /usr/bin/etags -L -
# etags (GNU Emacs 21.4.15)
ETAGS_STDIN = /usr/bin/etags -
DB_SQLITE_DBFILE = /tmp/phpwiki-sqlite.db
# ****************************************************************************
# get db params from config/config.ini
#DATABASE_TYPE=SQL
DATABASE_TYPE := $(shell config/make-dbhelper.pl -v=DATABASE_TYPE config/config.ini)
PROCESS_DSN=0
ifeq (${DATABASE_TYPE},SQL)
PROCESS_DSN=1
else
ifeq (${DATABASE_TYPE},ADODB)
PROCESS_DSN=1
endif
endif
ifeq (${PROCESS_DSN},1)
# get db params from config/config.ini DATABASE_DSN setting (only if SQL or ADODB)
DATABASE_DSN := $(shell config/make-dbhelper.pl -v=DATABASE_DSN config/config.ini)
#DB_DBTYPE=mysql
DB_DBTYPE := $(word 1,${DATABASE_DSN})
#DB_DB=phpwiki
DB_DB := $(word 2,${DATABASE_DSN})
#DB_USER=wikiuser
DB_USER := $(word 3,${DATABASE_DSN})
#DB_PASS=
DB_PASS := $(word 4,${DATABASE_DSN})
#Todo: read optional DBADMIN_USER and DBADMIN_PASS settings from config.ini
DBADMIN_OPTS=-u$(DBADMIN_USER) -p$(DBADMIN_PASS)
else
DB_DBTYPE=${DATABASE_TYPE}
endif
# ****************************************************************************
PHP_SRC := $(wildcard *.php ./lib/*.php ./lib/WikiDB/*.php ./lib/plugin/*.php)
.PHONY: all install locale mysql pqsql sqlite dbtest install-config
all: TAGS
TAGS: $(PHP_SRC)
if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
# etags $(PHP_SRC)
/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)
TAGS.full: $(PHP_SRC)
if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
/usr/bin/find . -name \*.php -o -name \*.tmpl | $(ETAGS_STDIN) --langmap="HTML:.tmpl" -f $@
# older etags needed this:
# /usr/bin/find . -type f -name \*.php -o -name \*.tmpl | etags - -o $@
locale:
cd locale
make
install: install-config install-database
install-config: config/config.ini
config/config.ini: config/config-dist.ini
cp config/config-dist.ini $@
echo "You must edit config/config.ini, at least set the ADMIN_PASSWD"
${EDITOR} $@
# helpers for database installation
install-database: ${DB_DBTYPE}
dba:
cvs:
# maybe setup permissions
file:
dbtest:
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)
# initialize the database
# TODO: compare /var/mysql/data/$(DB_DB) timestamp against schemas/mysql.sql
mysql:
mysqladmin $(DB_OPTS) create $(DB_DB)
mysql $(DB_OPTS) -e "GRANT select,insert,update,delete,lock tables ON $(DB_DB).* \
TO $(DB_USER)@localhost IDENTIFIED BY '$(DB_PASS)';"
mysql $(DB_OPTS) $(DB_DB) < schemas/mysql-initialize.sql
# initialize the database
pqsql:
su postmaster
createdb $(DB_DB)
ifeq ($(DB_PASS),"")
createuser -D -A -P $(DB_USER)
else
createuser -D -A $(DB_USER)
endif
psql $(DB_DB) -f schemas/psql-initialize.sql
logout
# initialize the database
sqlite: $(DB_SQLITE_DBFILE)
sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite-initialize.sql
# update the database
${DB_SQLITE_DBFILE}: schemas/sqlite.sql
echo ".dump" | sqlite ${DB_SQLITE_DBFILE} > dump.sql
mv ${DB_SQLITE_DBFILE} ${DB_SQLITE_DBFILE}.old
sqlite $(DB_SQLITE_DBFILE) < dump.sql
|