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