]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - Makefile
Translate quotes
[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 install: install-config install-database
80
81 install-config: config/config.ini
82
83 config/config.ini: config/config-dist.ini
84         cp config/config-dist.ini $@
85         echo "You must edit config/config.ini, at least set the ADMIN_PASSWD"
86         ${EDITOR} $@
87
88 # helpers for database installation
89 install-database: ${DB_DBTYPE}
90
91 dba:
92
93 cvs:
94
95 # maybe setup permissions
96 file:
97
98 dbtest:
99         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)
100
101 # initialize the database
102 # TODO: compare /var/mysql/data/$(DB_DB) timestamp against schemas/mysql.sql
103 mysql:
104         mysqladmin $(DB_OPTS) create $(DB_DB)
105         mysql $(DB_OPTS) -e "GRANT select,insert,update,delete,lock tables ON $(DB_DB).* \
106 TO $(DB_USER)@localhost IDENTIFIED BY '$(DB_PASS)';"
107         mysql $(DB_OPTS) $(DB_DB) < schemas/mysql-initialize.sql
108
109 # initialize the database
110 pqsql:
111         su postmaster
112         createdb $(DB_DB)
113         ifeq ($(DB_PASS),"")
114           createuser -D -A -P $(DB_USER)
115         else
116           createuser -D -A $(DB_USER)
117         endif
118         psql $(DB_DB) -f schemas/psql-initialize.sql
119         logout
120
121 # initialize the database
122 sqlite: $(DB_SQLITE_DBFILE)
123         sqlite $(DB_SQLITE_DBFILE) < schemas/sqlite-initialize.sql
124
125 # update the database
126 ${DB_SQLITE_DBFILE}: schemas/sqlite.sql
127         echo ".dump" | sqlite ${DB_SQLITE_DBFILE} > dump.sql
128         mv ${DB_SQLITE_DBFILE} ${DB_SQLITE_DBFILE}.old
129         sqlite $(DB_SQLITE_DBFILE) < dump.sql
130
131 dist: $(TARDIST)
132
133 cvstar: ../$(TARDIST)
134
135 # --exclude='\.*'
136 ../$(TARDIST) : $(PHP_SRC)
137           tar cfj $(TARDIST) --exclude=CVS \
138                 --exclude=config.ini \
139                 --exclude='*~'     \
140                 --exclude='*.bak'  \
141                 --exclude='*.orig' \
142                 --exclude='*.rej'  \
143                 --exclude=uploads  \
144                 --exclude=.patches \
145                 --exclude=TAGS     \
146                 --exclude=TAGS.full \
147                 --exclude='*.tar.bz2' \
148                 .
149
150 $(TARDIST) : $(PHP_SRC)
151         svn list -R | egrep -v "/\$" | tar cfj $(TARDIST)