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