Makefile 12.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# BEGIN LICENSE BLOCK
# 
# Copyright (c) 1996-2002 Jesse Vincent <jesse@bestpractical.com>
# 
# (Except where explictly superceded by other copyright notices)
# 
# This work is made available to you under the terms of Version 2 of
# the GNU General Public License. A copy of that license should have
# been provided with this software, but in any event can be snarfed
# from www.gnu.org
# 
# This work is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
# 
# 
# Unless otherwise specified, all modifications, corrections or
# extensions to this work which alter its source code become the
# property of Best Practical Solutions, LLC when submitted for
# inclusion in the work.
# 
# 
# END LICENSE BLOCK
25
26

PERL			= 	/usr/bin/perl
Jesse Vincent's avatar
Jesse Vincent committed
27

28
CONFIG_FILE_PATH	=	/opt/rt3/etc
29
CONFIG_FILE		= 	$(CONFIG_FILE_PATH)/RT_Config.pm
30

31
GETPARAM		=	$(PERL) -e'require "$(CONFIG_FILE)"; print $${$$RT::{$$ARGV[0]}};'
32

33
RT_VERSION_MAJOR	=	2
34
RT_VERSION_MINOR	=	1
35
RT_VERSION_PATCH	=	33
Jesse Vincent's avatar
Jesse Vincent committed
36

Jesse Vincent's avatar
Jesse Vincent committed
37
RT_VERSION =	$(RT_VERSION_MAJOR).$(RT_VERSION_MINOR).$(RT_VERSION_PATCH)
Jesse Vincent's avatar
Jesse Vincent committed
38
TAG 	   =	rt-$(RT_VERSION_MAJOR)-$(RT_VERSION_MINOR)-$(RT_VERSION_PATCH)
39

40

41
# This is the group that all of the installed files will be chgrp'ed to.
42
RTGROUP			=	rt
43

Tobias Brox's avatar
bgfx    
Tobias Brox committed
44

45
# User which should own rt binaries.
46
47
BIN_OWNER		=	root

48
# User that should own all of RT's libraries, generally root.
49
50
LIBS_OWNER 		=	root

51
# Group that should own all of RT's libraries, generally root.
52
53
LIBS_GROUP		=	bin

54
55
WEB_USER		=	`${GETPARAM} "WebUser"`
WEB_GROUP		=	`${GETPARAM} "WebGroup"`
56

57
58
# {{{ Files and directories 

59
60
61
62
63
64
# DESTDIR allows you to specify that RT be installed somewhere other than
# where it will eventually reside

DESTDIR			=	


65
66
67
68
69
70
71
72
73
74
75
RT_PATH			=	`$(GETPARAM) "BasePath"`
RT_ETC_PATH		=	`$(GETPARAM) "EtcPath"`
RT_BIN_PATH		=	`$(GETPARAM) "BinPath"`
RT_SBIN_PATH		=	`$(GETPARAM) "SbinPath"`
RT_LIB_PATH		=	`$(GETPARAM) "LibPath"`
RT_MAN_PATH		=	`$(GETPARAM) "ManPath"`
MASON_HTML_PATH		=	`$(GETPARAM) "MasonComponentRoot"`
MASON_LOCAL_HTML_PATH	=	`$(GETPARAM) "MasonLocalComponentRoot"`
MASON_DATA_PATH		=	`$(GETPARAM) "MasonDataDir"`
MASON_SESSION_PATH	=	`$(GETPARAM) "MasonSessionDir"`
RT_LOG_PATH             =       `$(GETPARAM) "LogDir"`
76

77
78
# RT_READABLE_DIR_MODE is the mode of directories that are generally meant
# to be accessable
79
80
81
82
RT_READABLE_DIR_MODE	=	0755



83
84

# {{{ all these define the places that RT's binaries should get installed
85

86
# RT_MODPERL_HANDLER is the mason handler script for mod_perl
87
RT_MODPERL_HANDLER	=	$(RT_BIN_PATH)/webmux.pl
88
# RT_FASTCGI_HANDLER is the mason handler script for FastCGI
89
RT_FASTCGI_HANDLER	=	$(RT_BIN_PATH)/mason_handler.fcgi
90
91
# RT_WIN32_FASTCGI_HANDLER is the mason handler script for FastCGI
RT_WIN32_FASTCGI_HANDLER	=	$(RT_BIN_PATH)/mason_handler.svc
92
# RT's CLI
93
RT_CLI_BIN		=	$(RT_BIN_PATH)/rt
94
# RT's admin CLI
95
RT_CLI_ADMIN_BIN	=	$(RT_BIN_PATH)/rtadmin
96
# RT's mail gateway
97
RT_MAILGATE_BIN		=	$(RT_BIN_PATH)/rt-mailgate
Jesse Vincent's avatar
Jesse Vincent committed
98
99
# RT's cron tool
RT_CRON_BIN		=	$(RT_BIN_PATH)/rt-crontool
Jesse Vincent's avatar
Jesse Vincent committed
100

101
102
103
104
105
106
107
108
# }}}

SETGID_BINARIES	 	= 	$(DESTDIR)/$(RT_MAILGATE_BIN) \
				$(DESTDIR)/$(RT_FASTCGI_HANDLER) \
				$(DESTDIR)/$(RT_CLI_BIN) \
				$(DESTDIR)/$(RT_CLI_ADMIN_BIN)

BINARIES		=	$(DESTDIR)/$(RT_MODPERL_HANDLER) \
Jesse Vincent's avatar
Jesse Vincent committed
109
				$(DESTDIR)/$(RT_CRON_BIN) \
110
111
112
113
				$(SETGID_BINARIES)
SYSTEM_BINARIES		=	$(DESTDIR)/$(RT_SBIN_PATH)/


114
# }}}
115

116
# {{{ Database setup
117

118
#
119
120
# DB_TYPE defines what sort of database RT trys to talk to
# "mysql" is known to work.
121
# "Pg" is known to work
122
# "Oracle" is in the early stages of working.
123

Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
124
DB_TYPE			=	`${GETPARAM} DatabaseType`
Jesse Vincent's avatar
Jesse Vincent committed
125
126

# Set DBA to the name of a unix account with the proper permissions and 
127
# environment to run your commandline SQL sbin
Jesse Vincent's avatar
Jesse Vincent committed
128
129

# Set DB_DBA to the name of a DB user with permission to create new databases 
130
131
# Set DB_DBA_PASSWORD to that user's password (if you don't, you'll be prompted
# later)
132

133
134
135
136
# For mysql, you probably want 'root'
# For Pg, you probably want 'postgres' 
# For oracle, you want 'system'

137
138
139
DB_DBA			=	`${GETPARAM} DatabaseDBA`
DB_DBA_PASSWORD		=	`${GETPARAM} DatabaseDBAPassword`
DB_HOST			=	`${GETPARAM} DatabaseHost`
140

141
142
143
144
# If you're not running your database server on its default port, 
# specifiy the port the database server is running on below.
# It's generally safe to leave this blank 

145
DB_PORT			=	`${GETPARAM} DatabasePort`
146

147
#
148
# Set this to the canonical name of the interface RT will be talking to the 
149
# database on.  If you said that the RT_DB_HOST above was "localhost," this 
150
# should be too. This value will be used to grant rt access to the database.
Jesse Vincent's avatar
Jesse Vincent committed
151
# If you want to access the RT database from multiple hosts, you'll need
152
# to grant those database rights by hand.
153
154
#

155
DB_RT_HOST		=	`${GETPARAM} DatabaseRTHost`
156

157
# set this to the name you want to give to the RT database in 
158
# your database server. For Oracle, this should be the name of your sid
159

160
161
162
DB_DATABASE		=	`${GETPARAM} DatabaseName`
DB_RT_USER		=	`${GETPARAM} DatabaseUser`
DB_RT_PASS		=	`${GETPARAM} DatabasePass`
163

164
# }}}
165
166


167
168
169
####################################################################
# No user servicable parts below this line.  Frob at your own risk #
####################################################################
170

171
172
all: default

173
default:
174
175
	@echo "Please read RT's readme before installing. Not doing so could"
	@echo "be dangerous."
176
177
178
179


instruct:
	@echo "Congratulations. RT has been installed. "
180
	@echo "You must now configure it by editing $(CONFIG_FILE)."
181
	@echo "From here on in, you should refer to the users guide."
182

183
184
185

upgrade-instruct: 
	@echo "Congratulations. RT has been upgraded. You should now check-over"
186
	@echo "$(CONFIG_FILE) for any necessarysite customization. Additionally,"
187
	@echo "you should update RT's system database objects by running "
188
	@echo "	   $(RT_SBIN_PATH)/insertdata <version>"
189
	@echo "where <version> is the version of RT you're upgrading from."
Jesse Vincent's avatar
Jesse Vincent committed
190

191

192
upgrade: dirs upgrade-noclobber  upgrade-instruct
193

194
upgrade-noclobber: libs-install html-install bin-install  fixperms
195
196


197
198
199
# {{{ dependencies
testdeps:
	$(PERL) ./sbin/testdeps -warn $(DB_TYPE)
200

201
202
fixdeps:
	$(PERL) ./sbin/testdeps -fix $(DB_TYPE)
203

204
#}}}
205

206
# {{{ fixperms
207
fixperms:
208
	# Make the libraries readable
209
210
211
	chmod -R $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_PATH)
	chown -R $(LIBS_OWNER) $(DESTDIR)/$(RT_LIB_PATH)
	chgrp -R $(LIBS_GROUP) $(DESTDIR)/$(RT_LIB_PATH)
212

213
214
	chown -R $(BIN_OWNER) $(DESTDIR)/$(RT_BIN_PATH)
	chgrp -R $(RTGROUP) $(DESTDIR)/$(RT_BIN_PATH)
215
216


217
218
	chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_BIN_PATH)
	chmod $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_BIN_PATH)	
219

220
221
	chmod 0755 $(DESTDIR)/$(RT_ETC_PATH)
	chmod 0500 $(DESTDIR)/$(RT_ETC_PATH)/*
222
223
224

	#TODO: the config file should probably be able to have its
	# owner set seperately from the binaries.
225
226
	chown -R $(BIN_OWNER) $(DESTDIR)/$(RT_ETC_PATH)
	chgrp -R $(RTGROUP) $(DESTDIR)/$(RT_ETC_PATH)
227

228
	chmod 0550 $(DESTDIR)/$(CONFIG_FILE)
229

230
	# Make the interfaces executable and setgid rt
231
232
233
234
235
	chown $(BIN_OWNER) $(SETGID_BINARIES)
	chgrp $(RTGROUP) $(SETGID_BINARIES)
	chmod 0755  $(SETGID_BINARIES)
	
	chmod g+s $(SETGID_BINARIES)
236
237

	# Make the web ui readable by all. 
238
239
240
241
242
243
	chmod -R  u+rwX,go-w,go+rX 	$(DESTDIR)/$(MASON_HTML_PATH) \
					$(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
	chown -R $(LIBS_OWNER) 	$(DESTDIR)/$(MASON_HTML_PATH) \
				$(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
	chgrp -R $(LIBS_GROUP) 	$(DESTDIR)/$(MASON_HTML_PATH) \
				$(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
244
245

	# Make the web ui's data dir writable
246
247
248
249
250
251
	chmod 0770  	$(DESTDIR)/$(MASON_DATA_PATH) \
			$(DESTDIR)/$(MASON_SESSION_PATH)
	chown -R $(WEB_USER) 	$(DESTDIR)/$(MASON_DATA_PATH) \
				$(DESTDIR)/$(MASON_SESSION_PATH)
	chgrp -R $(WEB_GROUP) 	$(DESTDIR)/$(MASON_DATA_PATH) \
				$(DESTDIR)/$(MASON_SESSION_PATH)
252
253
# }}}

Jesse Vincent's avatar
Jesse Vincent committed
254
255
fixperms-nosetgid: fixperms
	@echo "You should never be running RT this way. it's unsafe"
Jesse Vincent's avatar
Jesse Vincent committed
256
	chmod 0555 $(SETGID_BINARIES)
257
	chmod 0555 $(DESTDIR)/$(CONFIG_FILE)
Jesse Vincent's avatar
Jesse Vincent committed
258

259
# {{{ dirs
260
dirs:
261
	mkdir -p $(DESTDIR)/$(RT_LOG_PATH)
262
263
264
265
	mkdir -p $(DESTDIR)/$(MASON_DATA_PATH)
	mkdir -p $(DESTDIR)/$(MASON_SESSION_PATH)
	mkdir -p $(DESTDIR)/$(MASON_HTML_PATH)
	mkdir -p $(DESTDIR)/$(MASON_LOCAL_HTML_PATH)
266
# }}}
267

Jesse Vincent's avatar
Jesse Vincent committed
268
install: config-install dirs files-install initialize-database fixperms
269
270
271
272
273
274

files-install: libs-install etc-install bin-install sbin-install html-install

initialize-database: createdb insert-schema database-acl insert-baseline-data

config-install:
275
	mkdir -p $(DESTDIR)/$(CONFIG_FILE_PATH)	
276
277
278
279
	cp etc/RT_Config.pm $(DESTDIR)/$(CONFIG_FILE)
	chgrp $(RTGROUP) $(DESTDIR)/$(CONFIG_FILE)
	chown $(BIN_OWNER) $(DESTDIR)/$(CONFIG_FILE)

280
281
	@echo "Installed configuration. about to install rt in  $(RT_PATH)"

Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
282
test: 
Jesse Vincent's avatar
Jesse Vincent committed
283
	$(PERL) -Ilib lib/t/00smoke.t
Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
284

Jesse Vincent's avatar
Jesse Vincent committed
285
286
regression: config-install dirs files-install libs-install sbin-install bin-install regression-instruct dropdb initialize-database testify-pods
	$(PERL) lib/t/02regression.t
287
288
289
290

regression-quiet:
	$(PERL) sbin/regression_harness

Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
291
292
293
regression-instruct:
	@echo "About to wipe your database for a regression test. ABORT NOW with Control-C"

294
295
296
297
298
299
300
301
302
303
304
305
306
307

# {{{ database-installation
genschema:
	$(PERL)	$(DESTDIR)/$(RT_SBIN_PATH)/initdb generate

dropdb: 
	$(PERL)	$(DESTDIR)/$(RT_SBIN_PATH)/initdb drop 

database-acl:
	$(PERL) $(DESTDIR)/$(RT_SBIN_PATH)/initdb acl

createdb: 
	$(PERL)	$(DESTDIR)/$(RT_SBIN_PATH)/initdb create 

308
insert-schema: etc-install
309
310
311
	$(PERL)	$(DESTDIR)/$(RT_SBIN_PATH)/initdb insert

insert-baseline-data:
Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
312
	$(PERL)	$(DESTDIR)/$(RT_SBIN_PATH)/insertdata
313
314
315
316

# }}}

# {{{ libs-install
317
libs-install: 
318
319
320
321
	[ -d $(DESTDIR)/$(RT_LIB_PATH) ] || mkdir $(DESTDIR)/$(RT_LIB_PATH)
	chown -R $(LIBS_OWNER) $(DESTDIR)/$(RT_LIB_PATH)
	chgrp -R $(LIBS_GROUP) $(DESTDIR)/$(RT_LIB_PATH)
	chmod -R $(RT_READABLE_DIR_MODE) $(DESTDIR)/$(RT_LIB_PATH)
Jesse Vincent's avatar
Jesse Vincent committed
322
323
	cp -rp lib/* $(DESTDIR)/$(RT_LIB_PATH)
	$(PERL) -p -i -e " s'!!RT_VERSION!!'$(RT_VERSION)'g; \
324
	    			  s'!!RT_CONFIG!!'$(CONFIG_FILE)'g;" \
Jesse Vincent's avatar
Jesse Vincent committed
325
326
		$(DESTDIR)/$(RT_LIB_PATH)/RT.pm ; \

327
# }}}
328

329
# {{{ html-install
330
html-install:
331
	cp -rp ./html/* $(DESTDIR)/$(MASON_HTML_PATH)
332
# }}}
333

334
# {{{ etc-install
335

336
337
338
339
340
341
342
etc-install:
	mkdir -p $(DESTDIR)/$(RT_ETC_PATH)
	cp -rp \
		etc/acl.* \
		etc/schema.* \
		$(DESTDIR)/$(RT_ETC_PATH)
# }}}
343

344
# {{{ sbin-install
345

346
347
348
349
350
351
352
353
354
355
sbin-install:
	mkdir -p $(DESTDIR)/$(RT_SBIN_PATH)
	cp -rp \
		sbin/initdb \
		sbin/testdeps \
		sbin/insertdata \
		$(DESTDIR)/$(RT_SBIN_PATH)
	$(PERL) -p -i -e " s'!!PERL!!'"$(PERL)"'g;\
				s'!!RT_LIB_PATH!!'"$(RT_LIB_PATH)"'g;"\
		$(DESTDIR)/$(RT_SBIN_PATH)/*
356

357
# }}}
358

359
# {{{ bin-install
360

361
bin-install:
362
363
364
365
366
367
368
369
	@echo "Bin path is $(RT_BIN_PATH)"
	mkdir -p $(DESTDIR)/$(RT_BIN_PATH)
	cp -rp \
		bin/rt \
		bin/rtadmin \
		bin/rt-mailgate \
		bin/enhanced-mailgate \
		bin/mason_handler.fcgi \
370
		bin/mason_handler.svc \
371
		bin/webmux.pl \
Jesse Vincent's avatar
Jesse Vincent committed
372
		bin/rt-crontool \
373
374
375
		bin/rt-commit-handler \
		$(DESTDIR)/$(RT_BIN_PATH)
	$(PERL) -p -i -e " s'!!PERL!!'"$(PERL)"'g;\
376
				s'!!RT_LIB_PATH!!'"$(RT_LIB_PATH)"'g;"\
377
		$(BINARIES)
Jesse Vincent's avatar
Jesse Vincent committed
378
379
380
381




382
# }}}
Jesse Vincent's avatar
Jesse Vincent committed
383

384
# {{{ Best Practical Build targets -- no user servicable parts inside
Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
385

Jesse Vincent's avatar
Jesse Vincent committed
386
387
388
389
390
391

POD2TEST_EXE = sbin/extract_pod_tests

testify-pods:
	[ -d lib/t/autogen ] || mkdir lib/t/autogen
	find lib -name \*pm |xargs -n 1 $(PERL) $(POD2TEST_EXE)
392
	find bin -type f |grep -v \~| xargs -n 1 $(PERL) $(POD2TEST_EXE)
Jesse Vincent's avatar
Jesse Vincent committed
393
394
395



Jesse Vincent's avatar
Jesse Vincent committed
396
397
398
399
regenerate-catalogs:
	$(PERL) sbin/extract-message-catalog


Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
400
factory: createdb insert-schema
401
	cd lib; $(PERL) ../sbin/factory  $(DB_DATABASE) RT
Jesse Vincent's avatar
rt.2.1    
Jesse Vincent committed
402

Jesse Vincent's avatar
Jesse Vincent committed
403
commit:
404
	aegis -build ; aegis -diff ; aegis -test; aegis -develop_end
Jesse Vincent's avatar
RT 2.1    
Jesse Vincent committed
405
406

integrate:
407
	aegis -integrate_begin;	aegis -build; aegis -diff; aegis -test ; aegis -integrate_pass
Tobias Brox's avatar
Tobias Brox committed
408

409
410
411
412
predist: commit tag-and-tar

tag-and-release-baseline:
	aegis -cp -ind Makefile -output /tmp/Makefile.tagandrelease; \
413
	$(MAKE) -f /tmp/Makefile.tagandrelease tag-and-release
414
415
416
417
418
419
420
421
422
423


# Running this target in a working directory is 
# WRONG WRONG WRONG.
# it will tag the current baseline with the version of RT defined 
# in the currently-being-worked-on makefile. which is wrong.
#  you want tag-and-release-baseline

tag-and-release:
	aegis --delta-name $(TAG)
Jesse Vincent's avatar
Jesse Vincent committed
424
	rm -rf /tmp/$(TAG)
425
426
427
428
429
	mkdir /tmp/$(TAG)
	cd /tmp/$(TAG); \
		aegis -cp -ind -delta $(TAG) . ;\
		chmod 600 Makefile;\
		aegis --report --project rt.$(RT_VERSION_MAJOR) \
430
431
		      --page_width 80 \
		      --page_length 9999 \
432
433
		      --change $(RT_VERSION_MINOR) --output Changelog Change_Log

Jesse Vincent's avatar
Jesse Vincent committed
434
	cd /tmp; tar czvf /home/ftp/pub/rt/devel/$(TAG).tar.gz $(TAG)/
Jesse Vincent's avatar
Jesse Vincent committed
435
436
	chmod 644 /home/ftp/pub/rt/devel/$(TAG).tar.gz

437
438
rpm:
	(cd ..; tar czvf /usr/src/redhat/SOURCES/rt.tar.gz rt)
439
	rpm -ba etc/rt.spec
440
441


Jesse Vincent's avatar
Jesse Vincent committed
442
443
444
apachectl:
	/usr/sbin/apachectl stop
	/usr/sbin/apachectl start
445
# }}}