]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - Makefile
detect etags version
[SourceForge/phpwiki.git] / Makefile
1 # $Id: Makefile,v 1.13 2007-07-19 06:21:12 rurban Exp $
2 # user-definable settings:
3 # for mysqladmin
4 DBADMIN_USER=root
5 DBADMIN_PASS=secret
6
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 -
11 else
12   # new etags (GNU Emacs 21.5.x)
13   ETAGS_STDIN = /usr/bin/etags -L -
14 endif
15
16 DB_SQLITE_DBFILE = /tmp/phpwiki-sqlite.db
17
18 # ****************************************************************************
19 # get db params from config/config.ini
20
21 #DATABASE_TYPE=SQL
22 DATABASE_TYPE := $(shell config/make-dbhelper.pl -v=DATABASE_TYPE config/config.ini)
23 PROCESS_DSN=0
24 ifeq (${DATABASE_TYPE},SQL)
25   PROCESS_DSN=1
26 else
27   ifeq (${DATABASE_TYPE},ADODB) 
28     PROCESS_DSN=1
29   endif
30 endif
31
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)
35   #DB_DBTYPE=mysql
36   DB_DBTYPE := $(word 1,${DATABASE_DSN})
37   #DB_DB=phpwiki
38   DB_DB   := $(word 2,${DATABASE_DSN})
39   #DB_USER=wikiuser
40   DB_USER := $(word 3,${DATABASE_DSN})
41   #DB_PASS=
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)
45 else
46   DB_DBTYPE=${DATABASE_TYPE}
47 endif
48
49 # ****************************************************************************
50 PHP_SRC := $(wildcard *.php ./lib/*.php ./lib/WikiDB/*.php ./lib/plugin/*.php)
51
52 .PHONY: all install locale mysql pqsql sqlite dbtest install-config
53
54 all:  TAGS
55
56 TAGS:  $(PHP_SRC)
57         if [ -f $@ ]; then /usr/bin/mv -f $@ $@~; fi
58 #       etags $(PHP_SRC)
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)
60
61 TAGS.full:  $(PHP_SRC)
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 $@
66
67 locale: 
68         cd locale
69         make
70
71 install:        install-config install-database
72
73 install-config: config/config.ini
74
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"
78         ${EDITOR} $@
79
80 # helpers for database installation
81 install-database: ${DB_DBTYPE}
82
83 dba:
84
85 cvs:
86
87 # maybe setup permissions
88 file:
89
90 dbtest:
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)
92
93 # initialize the database
94 # TODO: compare /var/mysql/data/$(DB_DB) timestamp against schemas/mysql.sql
95 mysql:
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
100
101 # initialize the database
102 pqsql:
103         su postmaster
104         createdb $(DB_DB)
105         ifeq ($(DB_PASS),"")
106           createuser -D -A -P $(DB_USER)
107         else
108           createuser -D -A $(DB_USER)
109         endif
110         psql $(DB_DB) -f schemas/psql-initialize.sql
111         logout
112
113 # initialize the database
114 sqlite: $(DB_SQLITE_DBFILE)
115         sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite-initialize.sql
116
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