]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - Makefile
for new etags
[SourceForge/phpwiki.git] / Makefile
1 # $Id: Makefile,v 1.7 2004-11-03 16:47:53 rurban Exp $
2 # user-definable settings:
3 # for mysqladmin
4 DBADMIN_USER=root
5 DBADMIN_PASS=secret
6
7 DB_SQLITE_DBFILE = /tmp/phpwiki-sqlite.db
8
9 # ****************************************************************************
10 # get db params from config/config.ini
11
12 #DATABASE_TYPE=SQL
13 DATABASE_TYPE := $(shell config/make-dbhelper.pl -v=DATABASE_TYPE config/config.ini)
14 PROCESS_DSN=0
15 ifeq (${DATABASE_TYPE},SQL)
16   PROCESS_DSN=1
17 else
18   ifeq (${DATABASE_TYPE},ADODB) 
19     PROCESS_DSN=1
20   endif
21 endif
22
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)
26   #DB_DBTYPE=mysql
27   DB_DBTYPE := $(word 1,${DATABASE_DSN})
28   #DB_DB=phpwiki
29   DB_DB   := $(word 2,${DATABASE_DSN})
30   #DB_USER=wikiuser
31   DB_USER := $(word 3,${DATABASE_DSN})
32   #DB_PASS=
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)
36 else
37   DB_DBTYPE=${DATABASE_TYPE}
38 endif
39
40 # ****************************************************************************
41 PHP_SRC := $(wildcard *.php ./lib/*.php ./lib/WikiDB/*.php ./lib/plugin/*.php)
42
43 .PHONY: all install locale mysql pqsql sqlite dbtest
44
45 all:  TAGS
46
47 TAGS:  $(PHP_SRC)
48 #       etags $(PHP_SRC)
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 -type f -name \*.php | etags -
51
52 TAGS.full:  $(PHP_SRC)
53         if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
54 #       better etags
55 #       /usr/bin/find . -name \*.php -o -name \*.tmpl | etags -L - --langmap="HTML:.tmpl" -f $@
56         /usr/bin/find . -type f -name \*.php -o -name \*.tmpl | etags - -o $@
57
58 locale: 
59         cd locale
60         make
61
62 install:        install-config install-database
63
64 install-config: config/config.ini
65
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"
69         ${EDITOR} $@
70
71 # helpers for database installation
72 install-database: ${DB_DBTYPE}
73
74 dba:
75
76 cvs:
77
78 # maybe setup permissions
79 file:
80
81 dbtest:
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)
83
84 # initialize the database
85 # TODO: compare /var/mysql/data/$(DB_DB) timestamp against schemas/mysql.sql
86 mysql:
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
91
92 # initialize the database
93 pqsql:
94         su postmaster
95         createdb $(DB_DB)
96         ifeq ($(DB_PASS),"")
97           createuser -D -A -P $(DB_USER)
98         else
99           createuser -D -A $(DB_USER)
100         endif
101         psql $(DB_DB) -f schemas/psql-initialize.sql
102         logout
103
104 # initialize the database
105 sqlite: $(DB_SQLITE_DBFILE)
106         sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite-initialize.sql
107
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