00eba69fa4a459b835d3226912b24198a412e2ac
[freeside.git] / rt / Makefile
1 # BEGIN LICENSE BLOCK
2
3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4
5 # (Except where explictly superceded by other copyright notices)
6
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
10 # from www.gnu.org.
11
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
21
22
23 # END LICENSE BLOCK
24 #
25 # DO NOT HAND-EDIT the file named 'Makefile'. This file is autogenerated.
26 # Have a look at "configure" and "Makefile.in" instead
27 #
28
29
30 PERL                    =       /usr/bin/perl
31
32 CONFIG_FILE_PATH        =       /opt/rt3/etc
33 CONFIG_FILE             =       $(CONFIG_FILE_PATH)/RT_Config.pm
34 SITE_CONFIG_FILE                =       $(CONFIG_FILE_PATH)/RT_SiteConfig.pm
35
36
37 RT_VERSION_MAJOR        =       3
38 RT_VERSION_MINOR        =       4
39 RT_VERSION_PATCH        =       6
40
41 RT_VERSION =    $(RT_VERSION_MAJOR).$(RT_VERSION_MINOR).$(RT_VERSION_PATCH)
42 TAG        =    rt-$(RT_VERSION_MAJOR)-$(RT_VERSION_MINOR)-$(RT_VERSION_PATCH)
43
44
45 # This is the group that all of the installed files will be chgrp'ed to.
46 RTGROUP                 =       freeside
47
48
49 # User which should own rt binaries.
50 BIN_OWNER               =       root
51
52 # User that should own all of RT's libraries, generally root.
53 LIBS_OWNER              =       root
54
55 # Group that should own all of RT's libraries, generally root.
56 LIBS_GROUP              =       bin
57
58 WEB_USER                =       freeside
59 WEB_GROUP               =       freeside
60
61
62 APACHECTL               =       
63
64 # {{{ Files and directories 
65
66 # DESTDIR allows you to specify that RT be installed somewhere other than
67 # where it will eventually reside
68
69 DESTDIR                 =       
70
71
72 RT_PATH                 =       /opt/rt3
73 RT_ETC_PATH             =       /opt/rt3/etc
74 RT_BIN_PATH             =       /opt/rt3/bin
75 RT_SBIN_PATH            =       /opt/rt3/sbin
76 RT_LIB_PATH             =       /opt/rt3/lib
77 RT_MAN_PATH             =       /opt/rt3/man
78 RT_VAR_PATH             =       /opt/rt3/var
79 RT_DOC_PATH             =       /opt/rt3/share/doc
80 RT_LOCAL_PATH           =       /opt/rt3/local
81 LOCAL_ETC_PATH          =       /opt/rt3/local/etc
82 LOCAL_LEXICON_PATH      =       /opt/rt3/local/po
83 MASON_HTML_PATH         =       /opt/rt3/share/html
84 MASON_LOCAL_HTML_PATH   =       /opt/rt3/local/html
85 MASON_DATA_PATH         =       /opt/rt3/var/mason_data
86 MASON_SESSION_PATH      =       /opt/rt3/var/session_data
87 RT_LOG_PATH         =       /opt/rt3/var/log
88
89 # RT_READABLE_DIR_MODE is the mode of directories that are generally meant
90 # to be accessable
91 RT_READABLE_DIR_MODE    =       0755
92
93
94
95
96 # {{{ all these define the places that RT's binaries should get installed
97
98 # RT_MODPERL_HANDLER is the mason handler script for mod_perl
99 RT_MODPERL_HANDLER      =       $(RT_BIN_PATH)/webmux.pl
100 # RT_FASTCGI_HANDLER is the mason handler script for FastCGI
101 RT_FASTCGI_HANDLER      =       $(RT_BIN_PATH)/mason_handler.fcgi
102 # RT_WIN32_FASTCGI_HANDLER is the mason handler script for FastCGI
103 RT_WIN32_FASTCGI_HANDLER        =       $(RT_BIN_PATH)/mason_handler.svc
104 # RT's CLI
105 RT_CLI_BIN              =       $(RT_BIN_PATH)/rt
106 # RT's mail gateway
107 RT_MAILGATE_BIN         =       $(RT_BIN_PATH)/rt-mailgate
108 # RT's cron tool
109 RT_CRON_BIN             =       $(RT_BIN_PATH)/rt-crontool
110
111 # }}}
112
113 SETGID_BINARIES         =       $(DESTDIR)/$(RT_FASTCGI_HANDLER) \
114                                 $(DESTDIR)/$(RT_WIN32_FASTCGI_HANDLER)
115
116 BINARIES                =       $(DESTDIR)/$(RT_MODPERL_HANDLER) \
117                                 $(DESTDIR)/$(RT_MAILGATE_BIN) \
118                                 $(DESTDIR)/$(RT_CLI_BIN) \
119                                 $(DESTDIR)/$(RT_CRON_BIN) \
120                                 $(SETGID_BINARIES)
121 SYSTEM_BINARIES         =       $(DESTDIR)/$(RT_SBIN_PATH)/
122
123
124 # }}}
125
126 # {{{ Database setup
127
128 #
129 # DB_TYPE defines what sort of database RT trys to talk to
130 # "mysql" is known to work.
131 # "Pg" is known to work
132 # "Informix" is known to work
133
134 DB_TYPE                 =       Pg
135
136 # Set DBA to the name of a unix account with the proper permissions and 
137 # environment to run your commandline SQL sbin
138
139 # Set DB_DBA to the name of a DB user with permission to create new databases 
140
141 # For mysql, you probably want 'root'
142 # For Pg, you probably want 'postgres' 
143 # For Oracle, you want 'system'
144 # For Informix, you want 'informix'
145
146 DB_DBA                  =       freeside
147
148 DB_HOST                 =       localhost
149
150 # If you're not running your database server on its default port, 
151 # specifiy the port the database server is running on below.
152 # It's generally safe to leave this blank 
153
154 DB_PORT                 =       
155
156
157
158
159 #
160 # Set this to the canonical name of the interface RT will be talking to the 
161 # database on.  If you said that the RT_DB_HOST above was "localhost," this 
162 # should be too. This value will be used to grant rt access to the database.
163 # If you want to access the RT database from multiple hosts, you'll need
164 # to grant those database rights by hand.
165 #
166
167 DB_RT_HOST              =       localhost
168
169 # set this to the name you want to give to the RT database in 
170 # your database server. For Oracle, this should be the name of your sid
171
172 DB_DATABASE             =       _DBC_DBNAME_
173 DB_RT_USER              =       _DBC_DBUSER_
174 DB_RT_PASS              =       _DBC_DBPASS_
175
176 # }}}
177
178
179 ####################################################################
180
181 all: default
182
183 default:
184         @echo "Please read RT's readme before installing. Not doing so could"
185         @echo "be dangerous."
186
187
188
189 instruct:
190         @echo "Congratulations. RT has been installed. "
191         @echo ""
192         @echo ""
193         @echo "You must now configure RT by editing $(SITE_CONFIG_FILE)."
194         @echo ""
195         @echo "(You will definitely need to set RT's database password before continuing."
196         @echo " Not doing so could be very dangerous)"
197         @echo ""
198         @echo "After that, you need to initialize RT's database by running" 
199         @echo " 'make initialize-database'"
200
201 #       @echo " or by executing "       
202 #       @echo " '$(RT_SBIN_PATH)/rt-setup-database --action init \ "
203 #       @echo "     --dba $(DB_DBA) --prompt-for-dba-password'"
204
205
206
207 upgrade-instruct: 
208         @echo "Congratulations. RT has been upgraded. You should now check-over"
209         @echo "$(CONFIG_FILE) for any necessary site customization. Additionally,"
210         @echo "you should update RT's system database objects by running "
211         @echo "   ls etc/upgrade"
212         @echo ""
213         @echo "For each file in that directory whose name is greater than"
214         @echo "your previously installed RT version, run:"
215         @echo "    $(RT_SBIN_PATH)/rt-setup-database --dba $(DB_DBA) --prompt-for-dba-password --action schema --datadir etc/upgrade/<version>"
216         @echo "    $(RT_SBIN_PATH)/rt-setup-database --dba $(DB_DBA) --prompt-for-dba-password --action acl --datadir etc/upgrade/<version>"
217         @echo "    $(RT_SBIN_PATH)/rt-setup-database --dba $(DB_DBA) --prompt-for-dba-password --action insert --datadir etc/upgrade/<version>"
218
219 upgrade: config-install dirs files-install fixperms upgrade-instruct
220
221 upgrade-noclobber: config-install libs-install html-install bin-install local-install doc-install fixperms
222
223
224 # {{{ dependencies
225 testdeps:
226         $(PERL) ./sbin/rt-test-dependencies --verbose --with-$(DB_TYPE)
227
228 fixdeps:
229         $(PERL) ./sbin/rt-test-dependencies --verbose --install --with-$(DB_TYPE)
230
231 #}}}
232
233 # {{{ fixperms
234 fixperms:
235         # Make the libraries readable
236         chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_PATH)
237         chown -R $(LIBS_OWNER) $(DESTDIR)/$(RT_LIB_PATH)
238         chgrp -R $(LIBS_GROUP) $(DESTDIR)/$(RT_LIB_PATH)
239         chmod -R  u+rwX,go-w,go+rX      $(DESTDIR)/$(RT_LIB_PATH)
240
241
242         chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_BIN_PATH)
243         chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_BIN_PATH) 
244
245         chmod 0755 $(DESTDIR)/$(RT_ETC_PATH)
246         chmod 0500 $(DESTDIR)/$(RT_ETC_PATH)/*
247
248         #TODO: the config file should probably be able to have its
249         # owner set separately from the binaries.
250         chown -R $(BIN_OWNER) $(DESTDIR)/$(RT_ETC_PATH)
251         chgrp -R $(RTGROUP) $(DESTDIR)/$(RT_ETC_PATH)
252
253         chmod 0550 $(DESTDIR)/$(CONFIG_FILE)
254         chmod 0550 $(DESTDIR)/$(SITE_CONFIG_FILE)
255
256         # Make the interfaces executable
257         chown $(BIN_OWNER) $(BINARIES)
258         chgrp $(RTGROUP) $(BINARIES)
259         chmod 0755  $(BINARIES)
260
261         # Make the web ui readable by all. 
262         chmod -R  u+rwX,go-w,go+rX      $(DESTDIR)/$(MASON_HTML_PATH) \
263                                         $(DESTDIR)/$(MASON_LOCAL_HTML_PATH) \
264                                         $(DESTDIR)/$(LOCAL_LEXICON_PATH)
265         chown -R $(LIBS_OWNER)  $(DESTDIR)/$(MASON_HTML_PATH) \
266                                 $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
267         chgrp -R $(LIBS_GROUP)  $(DESTDIR)/$(MASON_HTML_PATH) \
268                                 $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
269
270         # Make the web ui's data dir writable
271         chmod 0770      $(DESTDIR)/$(MASON_DATA_PATH) \
272                         $(DESTDIR)/$(MASON_SESSION_PATH)
273         chown -R $(WEB_USER)    $(DESTDIR)/$(MASON_DATA_PATH) \
274                                 $(DESTDIR)/$(MASON_SESSION_PATH)
275         chgrp -R $(WEB_GROUP)   $(DESTDIR)/$(MASON_DATA_PATH) \
276                                 $(DESTDIR)/$(MASON_SESSION_PATH)
277 # }}}
278
279 # {{{ dirs
280 dirs:
281         mkdir -p $(DESTDIR)/$(RT_LOG_PATH)
282         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)
283         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)/cache
284         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)/etc
285         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)/obj
286         mkdir -p $(DESTDIR)/$(MASON_SESSION_PATH)
287         mkdir -p $(DESTDIR)/$(MASON_HTML_PATH)
288         mkdir -p $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
289         mkdir -p $(DESTDIR)/$(LOCAL_ETC_PATH)
290         mkdir -p $(DESTDIR)/$(LOCAL_LIB_PATH)
291         mkdir -p $(DESTDIR)/$(LOCAL_LEXICON_PATH)
292 # }}}
293
294 install: config-install dirs files-install fixperms instruct
295
296 files-install: libs-install etc-install bin-install sbin-install html-install local-install doc-install
297
298 config-install:
299         mkdir -p $(DESTDIR)/$(CONFIG_FILE_PATH) 
300         -cp etc/RT_Config.pm $(DESTDIR)/$(CONFIG_FILE)
301         [ -f $(DESTDIR)/$(SITE_CONFIG_FILE) ] || cp etc/RT_SiteConfig.pm $(DESTDIR)/$(SITE_CONFIG_FILE) 
302
303         chgrp $(RTGROUP) $(DESTDIR)/$(CONFIG_FILE)
304         chown $(BIN_OWNER) $(DESTDIR)/$(CONFIG_FILE)
305
306         chgrp $(RTGROUP) $(DESTDIR)/$(SITE_CONFIG_FILE)
307         chown $(BIN_OWNER) $(DESTDIR)/$(SITE_CONFIG_FILE)
308
309         @echo "Installed configuration. about to install rt in  $(RT_PATH)"
310
311 test: 
312         $(PERL) -Ilib lib/t/00smoke.t
313
314 regression-install: config-install
315         $(PERL) -pi -e 's/Set\(\$$DatabaseName.*\);/Set\(\$$DatabaseName, "rt3regression"\);/' $(DESTDIR)/$(CONFIG_FILE)
316
317 regression: regression-install dirs files-install libs-install sbin-install bin-install regression-instruct regression-reset-db  testify-pods fixperms apachectl run-regression
318
319 run-regression:
320         prove -Ilib lib/t/setup_regression.t  lib/t/autogen/ lib/t/regression/
321
322 regression-noapache: regression-install dirs files-install libs-install sbin-install bin-install regression-instruct regression-reset-db  testify-pods fixperms start-httpd  run-regression
323
324 regression-quiet:
325         $(PERL) sbin/regression_harness
326
327 regression-instruct:
328         @echo "About to wipe your database for a regression test. ABORT NOW with Control-C"
329
330
331 # {{{ database-installation
332
333 regression-reset-db:
334         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/rt-setup-database --action drop --dba $(DB_DBA) --dba-password '' --force
335         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/rt-setup-database --action init --dba $(DB_DBA) --dba-password ''
336
337 initdb :: initialize-database
338
339 initialize-database: 
340         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/rt-setup-database --action init --dba $(DB_DBA) --prompt-for-dba-password
341
342 dropdb: 
343         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/rt-setup-database --action drop --dba $(DB_DBA) --prompt-for-dba-password
344
345 insert-approval-data: 
346         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/insert_approval_scrips
347 # }}}
348
349 # {{{ libs-install
350 libs-install: 
351         [ -d $(DESTDIR)/$(RT_LIB_PATH) ] || mkdir -p $(DESTDIR)/$(RT_LIB_PATH)
352         -cp -rp lib/* $(DESTDIR)/$(RT_LIB_PATH)
353 # }}}
354
355 # {{{ html-install
356 html-install:
357         [ -d $(DESTDIR)/$(MASON_HTML_PATH) ] || mkdir $(DESTDIR)/$(MASON_HTML_PATH)
358         -cp -rp ./html/* $(DESTDIR)/$(MASON_HTML_PATH)
359 # }}}
360
361 # {{{ doc-install
362 doc-install:
363         # RT 3.0.0 - RT 3.0.2 would accidentally create a file instead of a dir
364         -[ -f $(DESTDIR)/$(RT_DOC_PATH) ] && rm $(DESTDIR)/$(RT_DOC_PATH) 
365         [ -d $(DESTDIR)/$(RT_DOC_PATH) ] || mkdir $(DESTDIR)/$(RT_DOC_PATH)
366         -cp -rp ./README $(DESTDIR)/$(RT_DOC_PATH)
367 # }}}
368
369 # {{{ etc-install
370
371 etc-install:
372         mkdir -p $(DESTDIR)/$(RT_ETC_PATH)
373         -cp -rp \
374                 etc/acl.* \
375                 etc/initialdata \
376                 etc/schema.* \
377                 $(DESTDIR)/$(RT_ETC_PATH)
378 # }}}
379
380 # {{{ sbin-install
381
382 sbin-install:
383         mkdir -p $(DESTDIR)/$(RT_SBIN_PATH)
384         chmod +x \
385                 sbin/rt-dump-database \
386                 sbin/rt-setup-database \
387                 sbin/rt-test-dependencies
388         -cp -rp \
389                 sbin/rt-dump-database \
390                 sbin/rt-setup-database \
391                 sbin/rt-test-dependencies \
392                 $(DESTDIR)/$(RT_SBIN_PATH)
393
394 # }}}
395
396 # {{{ bin-install
397
398 bin-install:
399         mkdir -p $(DESTDIR)/$(RT_BIN_PATH)
400         chmod +x bin/rt-mailgate \
401                 bin/rt-crontool
402         -cp -rp \
403                 bin/rt-mailgate \
404                 bin/mason_handler.fcgi \
405                 bin/mason_handler.scgi \
406                 bin/standalone_httpd \
407                 bin/mason_handler.svc \
408                 bin/rt \
409                 bin/webmux.pl \
410                 bin/rt-crontool \
411                 $(DESTDIR)/$(RT_BIN_PATH)
412 # }}}
413
414 # {{{ local-install
415 local-install:
416         -cp -rp ./local/html/* $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
417         -cp -rp ./local/po/* $(DESTDIR)/$(LOCAL_LEXICON_PATH)
418         -cp -rp ./local/etc/* $(DESTDIR)/$(LOCAL_ETC_PATH)
419 # }}}
420
421 # {{{ Best Practical Build targets -- no user servicable parts inside
422
423
424 POD2TEST_EXE = sbin/extract_pod_tests
425
426 testify-pods:
427         [ -d lib/t/autogen ] || mkdir lib/t/autogen
428         find lib -name \*pm |grep -v .svn | grep -v \*.in |xargs -n 1 $(PERL) $(POD2TEST_EXE)
429         find bin -type f |grep -v .svn | grep -v \~ | grep -v "\.in" | xargs -n 1 $(PERL) $(POD2TEST_EXE)
430         find lib -name \*pm |grep -v .svn | grep -v \*.in |xargs -n 1 $(PERL) $(POD2TEST_EXE)
431         find bin -type f |grep -v .svn | grep -v \~ | grep -v "\.in" | xargs -n 1 $(PERL) $(POD2TEST_EXE)
432
433
434
435 regenerate-catalogs:
436         $(PERL) sbin/extract-message-catalog
437
438 license-tag:
439         $(PERL) sbin/license_tag
440
441 factory: initialize-database
442         cd lib; $(PERL) ../sbin/factory  $(DB_DATABASE) RT
443
444 reconfigure:
445         aclocal -I m4
446         autoconf
447         chmod 755 ./configure
448         ./configure
449
450 apachectl:
451         $(APACHECTL) stop
452         sleep 10
453         $(APACHECTL) start
454 # }}}