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