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