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