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