acquire a database lock to prevent race conditions in duplicate checking
[freeside.git] / rt / Makefile
1 # BEGIN LICENSE BLOCK
2
3 # Copyright (c) 1996-2002 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
18 # Unless otherwise specified, all modifications, corrections or
19 # extensions to this work which alter its source code become the
20 # property of Best Practical Solutions, LLC when submitted for
21 # inclusion in the work.
22
23
24 # END LICENSE BLOCK
25
26
27 #
28 # DO NOT HAND-EDIT the file named 'Makefile'. This file is autogenerated.
29 # Have a look at "configure" and "Makefile.in" instead
30 #
31
32
33 PERL                    =       /usr/bin/perl
34
35 CONFIG_FILE_PATH        =       /opt/rt3/etc
36 CONFIG_FILE             =       $(CONFIG_FILE_PATH)/RT_Config.pm
37 SITE_CONFIG_FILE                =       $(CONFIG_FILE_PATH)/RT_SiteConfig.pm
38
39
40 RT_VERSION_MAJOR        =       3
41 RT_VERSION_MINOR        =       0
42 RT_VERSION_PATCH        =       4
43
44 RT_VERSION =    $(RT_VERSION_MAJOR).$(RT_VERSION_MINOR).$(RT_VERSION_PATCH)
45 TAG        =    rt-$(RT_VERSION_MAJOR)-$(RT_VERSION_MINOR)-$(RT_VERSION_PATCH)
46
47
48 # This is the group that all of the installed files will be chgrp'ed to.
49 RTGROUP                 =       rt
50
51
52 # User which should own rt binaries.
53 BIN_OWNER               =       root
54
55 # User that should own all of RT's libraries, generally root.
56 LIBS_OWNER              =       root
57
58 # Group that should own all of RT's libraries, generally root.
59 LIBS_GROUP              =       bin
60
61 WEB_USER                =       www
62 WEB_GROUP               =       www
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 admin CLI
105 RT_CLI_ADMIN_BIN        =       $(RT_BIN_PATH)/rtadmin
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_CRON_BIN) \
119                                 $(SETGID_BINARIES)
120 SYSTEM_BINARIES         =       $(DESTDIR)/$(RT_SBIN_PATH)/
121
122
123 # }}}
124
125 # {{{ Database setup
126
127 #
128 # DB_TYPE defines what sort of database RT trys to talk to
129 # "mysql" is known to work.
130 # "Pg" is known to work
131
132 DB_TYPE                 =       mysql
133
134 # Set DBA to the name of a unix account with the proper permissions and 
135 # environment to run your commandline SQL sbin
136
137 # Set DB_DBA to the name of a DB user with permission to create new databases 
138
139 # For mysql, you probably want 'root'
140 # For Pg, you probably want 'postgres' 
141 # For oracle, you want 'system'
142
143 DB_DBA                  =       root
144
145 DB_HOST                 =       localhost
146
147 # If you're not running your database server on its default port, 
148 # specifiy the port the database server is running on below.
149 # It's generally safe to leave this blank 
150
151 DB_PORT                 =       
152
153
154
155
156 #
157 # Set this to the canonical name of the interface RT will be talking to the 
158 # database on.  If you said that the RT_DB_HOST above was "localhost," this 
159 # should be too. This value will be used to grant rt access to the database.
160 # If you want to access the RT database from multiple hosts, you'll need
161 # to grant those database rights by hand.
162 #
163
164 DB_RT_HOST              =       localhost
165
166 # set this to the name you want to give to the RT database in 
167 # your database server. For Oracle, this should be the name of your sid
168
169 DB_DATABASE             =       rt3
170 DB_RT_USER              =       rt_user
171 DB_RT_PASS              =       rt_pass
172
173 # }}}
174
175
176 ####################################################################
177
178 all: default
179
180 default:
181         @echo "Please read RT's readme before installing. Not doing so could"
182         @echo "be dangerous."
183
184
185
186 instruct:
187         @echo "Congratulations. RT has been installed. "
188         @echo ""
189         @echo ""
190         @echo "You must now configure RT by editing $(SITE_CONFIG_FILE)."
191         @echo ""
192         @echo "(You will definitely need to set RT's database password before continuing."
193         @echo " Not doing so could be very dangerous)"
194         @echo ""
195         @echo "After that, you need to initialize RT's database by running" 
196         @echo " 'make initialize-database'"
197
198 #       @echo " or by executing "       
199 #       @echo " '$(RT_SBIN_PATH)/rt-setup-database --action init \ "
200 #       @echo "     --dba $(DB_DBA) --prompt-for-dba-password'"
201
202
203
204 upgrade-instruct: 
205         @echo "Congratulations. RT has been upgraded. You should now check-over"
206         @echo "$(CONFIG_FILE) for any necessary site customization. Additionally,"
207         @echo "you should update RT's system database objects by running "
208         @echo "   ls etc/upgrade"
209         @echo "For each file in that directory whose name is greater than"
210         @echo "your previously installed RT version, run:"
211         @echo "    $(RT_SBIN_PATH)/rt-setup-database --action insert --datafile etc/upgrade/<version>"
212
213
214 upgrade: dirs upgrade-noclobber upgrade-instruct
215
216 upgrade-noclobber: config-install libs-install html-install bin-install local-install doc-install fixperms
217
218
219 # {{{ dependencies
220 testdeps:
221         $(PERL) ./sbin/rt-test-dependencies --with-$(DB_TYPE)
222
223 fixdeps:
224         $(PERL) ./sbin/rt-test-dependencies --install --with-$(DB_TYPE)
225
226 #}}}
227
228 # {{{ fixperms
229 fixperms:
230         # Make the libraries readable
231         chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_PATH)
232         chown -R $(LIBS_OWNER) $(DESTDIR)/$(RT_LIB_PATH)
233         chgrp -R $(LIBS_GROUP) $(DESTDIR)/$(RT_LIB_PATH)
234         chmod -R  u+rwX,go-w,go+rX      $(DESTDIR)/$(RT_LIB_PATH)
235
236
237         chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_BIN_PATH)
238         chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_BIN_PATH) 
239
240         chmod 0755 $(DESTDIR)/$(RT_ETC_PATH)
241         chmod 0500 $(DESTDIR)/$(RT_ETC_PATH)/*
242
243         #TODO: the config file should probably be able to have its
244         # owner set seperately from the binaries.
245         chown -R $(BIN_OWNER) $(DESTDIR)/$(RT_ETC_PATH)
246         chgrp -R $(RTGROUP) $(DESTDIR)/$(RT_ETC_PATH)
247
248         chmod 0550 $(DESTDIR)/$(CONFIG_FILE)
249         chmod 0550 $(DESTDIR)/$(SITE_CONFIG_FILE)
250
251         # Make the interfaces executable and setgid rt
252         chown $(BIN_OWNER) $(BINARIES)
253         chgrp $(RTGROUP) $(BINARIES)
254         chmod 0755  $(BINARIES)
255         chmod g+s $(SETGID_BINARIES)
256
257         # Make the web ui readable by all. 
258         chmod -R  u+rwX,go-w,go+rX      $(DESTDIR)/$(MASON_HTML_PATH) \
259                                         $(DESTDIR)/$(MASON_LOCAL_HTML_PATH) \
260                                         $(DESTDIR)/$(LOCAL_LEXICON_PATH)
261         chown -R $(LIBS_OWNER)  $(DESTDIR)/$(MASON_HTML_PATH) \
262                                 $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
263         chgrp -R $(LIBS_GROUP)  $(DESTDIR)/$(MASON_HTML_PATH) \
264                                 $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
265
266         # Make the web ui's data dir writable
267         chmod 0770      $(DESTDIR)/$(MASON_DATA_PATH) \
268                         $(DESTDIR)/$(MASON_SESSION_PATH)
269         chown -R $(WEB_USER)    $(DESTDIR)/$(MASON_DATA_PATH) \
270                                 $(DESTDIR)/$(MASON_SESSION_PATH)
271         chgrp -R $(WEB_GROUP)   $(DESTDIR)/$(MASON_DATA_PATH) \
272                                 $(DESTDIR)/$(MASON_SESSION_PATH)
273 # }}}
274
275 fixperms-nosetgid: fixperms
276         @echo "You should never be running RT this way. it's unsafe"
277         chmod 0555 $(SETGID_BINARIES)
278         chmod 0555 $(DESTDIR)/$(CONFIG_FILE)
279         chmod 0555 $(DESTDIR)/$(SITE_CONFIG_FILE)
280
281 # {{{ dirs
282 dirs:
283         mkdir -p $(DESTDIR)/$(RT_LOG_PATH)
284         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)
285         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)/cache
286         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)/etc
287         mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)/obj
288         mkdir -p $(DESTDIR)/$(MASON_SESSION_PATH)
289         mkdir -p $(DESTDIR)/$(MASON_HTML_PATH)
290         mkdir -p $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
291         mkdir -p $(DESTDIR)/$(LOCAL_ETC_PATH)
292         mkdir -p $(DESTDIR)/$(LOCAL_LEXICON_PATH)
293 # }}}
294
295 install: config-install dirs files-install fixperms instruct
296
297 files-install: libs-install etc-install bin-install sbin-install html-install local-install doc-install
298
299 config-install:
300         mkdir -p $(DESTDIR)/$(CONFIG_FILE_PATH) 
301         cp etc/RT_Config.pm $(DESTDIR)/$(CONFIG_FILE)
302         [ -f $(DESTDIR)/$(SITE_CONFIG_FILE) ] || cp etc/RT_SiteConfig.pm $(DESTDIR)/$(SITE_CONFIG_FILE) 
303
304         chgrp $(RTGROUP) $(DESTDIR)/$(CONFIG_FILE)
305         chown $(BIN_OWNER) $(DESTDIR)/$(CONFIG_FILE)
306
307         chgrp $(RTGROUP) $(DESTDIR)/$(SITE_CONFIG_FILE)
308         chown $(BIN_OWNER) $(DESTDIR)/$(SITE_CONFIG_FILE)
309
310         @echo "Installed configuration. about to install rt in  $(RT_PATH)"
311
312 test: 
313         $(PERL) -Ilib lib/t/00smoke.t
314
315 regression-nosetgid-quiet: config-install dirs files-install libs-install sbin-install bin-install regression-instruct regression-reset-db  testify-pods fixperms-nosetgid apachectl
316         $(PERL) sbin/regression_harness
317
318 regression-nosetgid: config-install dirs files-install libs-install sbin-install bin-install regression-instruct regression-reset-db  testify-pods fixperms-nosetgid apachectl
319         $(PERL) lib/t/02regression.t
320
321 regression: config-install dirs files-install libs-install sbin-install bin-install regression-instruct regression-reset-db  testify-pods apachectl
322         $(PERL) lib/t/02regression.t
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 ''
335         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/rt-setup-database --action init --dba $(DB_DBA) --dba-password ''
336
337 initialize-database: 
338         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/rt-setup-database --action init --dba $(DB_DBA) --prompt-for-dba-password
339
340 dropdb: 
341         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/rt-setup-database --action drop --dba $(DB_DBA) --prompt-for-dba-password
342
343 insert-approval-data: 
344         $(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/insert_approval_scrips
345 # }}}
346
347 # {{{ libs-install
348 libs-install: 
349         [ -d $(DESTDIR)/$(RT_LIB_PATH) ] || mkdir $(DESTDIR)/$(RT_LIB_PATH)
350         -cp -rp lib/* $(DESTDIR)/$(RT_LIB_PATH)
351 # }}}
352
353 # {{{ html-install
354 html-install:
355         [ -d $(DESTDIR)/$(MASON_HTML_PATH) ] || mkdir $(DESTDIR)/$(MASON_HTML_PATH)
356         -cp -rp ./html/* $(DESTDIR)/$(MASON_HTML_PATH)
357 # }}}
358
359 # {{{ doc-install
360 doc-install:
361         # RT 3.0.0 - RT 3.0.2 would accidentally create a file instead of a dir
362         -[ -f $(DESTDIR)/$(RT_DOC_PATH) ] && rm $(DESTDIR)/$(RT_DOC_PATH) 
363         [ -d $(DESTDIR)/$(RT_DOC_PATH) ] || mkdir $(DESTDIR)/$(RT_DOC_PATH)
364         -cp -rp ./README $(DESTDIR)/$(RT_DOC_PATH)
365 # }}}
366
367 # {{{ etc-install
368
369 etc-install:
370         mkdir -p $(DESTDIR)/$(RT_ETC_PATH)
371         -cp -rp \
372                 etc/acl.* \
373                 etc/initialdata \
374                 etc/schema.* \
375                 $(DESTDIR)/$(RT_ETC_PATH)
376 # }}}
377
378 # {{{ sbin-install
379
380 sbin-install:
381         mkdir -p $(DESTDIR)/$(RT_SBIN_PATH)
382         chmod +x sbin/rt-setup-database \
383                 sbin/rt-test-dependencies
384         -cp -rp \
385                 sbin/rt-setup-database \
386                 sbin/rt-test-dependencies \
387                 $(DESTDIR)/$(RT_SBIN_PATH)
388
389 # }}}
390
391 # {{{ bin-install
392
393 bin-install:
394         mkdir -p $(DESTDIR)/$(RT_BIN_PATH)
395         chmod +x bin/rt-mailgate \
396                 bin/rt-crontool
397         -cp -rp \
398                 bin/rt-mailgate \
399                 bin/mason_handler.fcgi \
400                 bin/mason_handler.svc \
401                 bin/webmux.pl \
402                 bin/rt-crontool \
403                 $(DESTDIR)/$(RT_BIN_PATH)
404 # }}}
405
406 # {{{ local-install
407 local-install:
408         -cp -rp ./local/html/* $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
409         -cp -rp ./local/po/* $(DESTDIR)/$(LOCAL_LEXICON_PATH)
410         -cp -rp ./local/etc/* $(DESTDIR)/$(LOCAL_ETC_PATH)
411 # }}}
412
413 # {{{ Best Practical Build targets -- no user servicable parts inside
414
415
416 POD2TEST_EXE = sbin/extract_pod_tests
417
418 testify-pods:
419         [ -d lib/t/autogen ] || mkdir lib/t/autogen
420         find lib -name \*pm |grep -v \*.in |xargs -n 1 $(PERL) $(POD2TEST_EXE)
421         find bin -type f |grep -v \~ | grep -v "\.in" | xargs -n 1 $(PERL) $(POD2TEST_EXE)
422
423
424
425 regenerate-catalogs:
426         $(PERL) sbin/extract-message-catalog
427
428 license-tag:
429         $(PERL) sbin/license_tag
430
431 factory: initialize-database
432         cd lib; $(PERL) ../sbin/factory  $(DB_DATABASE) RT
433
434 commit:
435         aegis -build ; aegis -diff ; aegis -test; aegis -develop_end
436
437 integrate:
438         aegis -integrate_begin; aegis -build; aegis -diff; aegis -test ; aegis -integrate_pass
439
440 predist: commit tag-and-tar
441
442 tag-and-release-baseline:
443         aegis -cp -ind Makefile -output /tmp/Makefile.tagandrelease; \
444         $(MAKE) -f /tmp/Makefile.tagandrelease tag-and-release-never-by-hand
445
446
447 # Running this target in a working directory is 
448 # WRONG WRONG WRONG.
449 # it will tag the current baseline with the version of RT defined 
450 # in the currently-being-worked-on makefile. which is wrong.
451 #  you want tag-and-release-baseline
452
453 tag-and-release-never-by-hand:
454         aegis --delta-name $(TAG)
455         rm -rf /tmp/$(TAG)
456         mkdir /tmp/$(TAG)
457         cd /tmp/$(TAG); \
458                 aegis -cp -ind -delta $(TAG) . ;\
459                 make reconfigure;\
460                 chmod 600 Makefile;\
461                 aegis --report --project rt.$(RT_VERSION_MAJOR) \
462                       --page_width 80 \
463                       --page_length 9999 \
464                       --change $(RT_VERSION_MINOR) --output Changelog Change_Log
465
466         cd /tmp; tar czvf /home/ftp/pub/rt/devel/$(TAG).tar.gz $(TAG)/
467         chmod 644 /home/ftp/pub/rt/devel/$(TAG).tar.gz
468
469
470 reconfigure:
471         aclocal -I m4
472         autoconf
473         chmod 755 ./configure
474         ./configure
475
476 rpm:
477         (cd ..; tar czvf /usr/src/redhat/SOURCES/rt.tar.gz rt)
478         rpm -ba etc/rt.spec
479
480
481 apachectl:
482         apachectl stop
483         sleep 3
484         apachectl start
485 # }}}