summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 06dd8ea2aa0cf486a08044e6714a81972db513bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
#!/usr/bin/make -f
# -*- makefile -*- 
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
#
# This file is also based upon prior sendmail makefiles 
#
# This file will make sendmail on either slink or potato, the only thing
# to watch for is to make sure the changelog correctly reflects the
# appropriate distribution!
#
# Richard Nelson <cowboy@debian.org>

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=

# This has to be exported to make some magic below work.
export DH_OPTIONS

package=sendmail
version=$(shell expr `pwd` : '.*-\([0-9.].*\)')
version_main=$(shell expr `pwd` : '.*-\([0-9]*.[0-9.]*\)')

# Many things depend upon which release (slink, potato, etc.)
ifeq ("$(shell dh_testversion 2.0.40 && echo potato)", "potato")
	DH_COMPAT = 2
	TEMP_DIR  = $(shell echo "debian/tmp debian/$(package)" | \
		    cut -d " " -f $(DH_COMPAT))
	DOC_PFX   = usr/share/doc
	MAN_PFX   = usr/share/man
else
	DH_COMPAT = 1
	TEMP_DIR  = debian/tmp
	DOC_PFX   = usr/doc
	MAN_PFX   = usr/man
	endif

export DH_COMPAT
MAN_DIR="$(TEMP_DIR)/$(MAN_PFX)"
DOC_DIR="$(TEMP_DIR)/$(DOC_PFX)"


#-------------
info:

	#--------------------------------------------------------------------
	# The following information will be used for this run:
	#   Package    = $(package)
	#   version    = $(version)
	#   DH_VERBOSE = $(DH_VERBOSE)
	#   DH_OPTIONS = $(DH_OPTIONS)
	#   DH_COMPAT  = $(DH_COMPAT)
	#   TEMP_DIR   = $(TEMP_DIR)
	#   MAN_PFX    = $(MAN_PFX)
	#   DOC_PFX    = $(DOC_PFX)
	#--------------------------------------------------------------------


#-------------
setup: setup-stamp
setup-stamp: info

	# Mark some files executable, dpkg-source -x undoes me here...
	chmod a+x \
		debian/rules \
		debian/local/configure \
		debian/local/sendmailconfig \
		debian/local/updatedb \
		debian/local/parsemc

	# Create proper debian/$(package).dirs file
	# This way, we can build for either slink or potato
	sed "s?MAN_PFX?$(MAN_PFX)?g" \
		debian/$(package).dirs.template \
		| sed "s?\DOC_PFX?$(DOC_PFX)?g" \
		> debian/$(package).dirs

	# Use autoconf for some Slink/Potato differences
	#cd debian/local && autoconf
	cd debian/local && ./configure

	touch setup-stamp


#-------------
clean:
	dh_testdir
	dh_testroot
	rm -f setup-stamp build-stamp install-stamp

	# Add here commands to clean up after the build process.
	#-$(MAKE) clean
	#-$(MAKE) distclean

	# First, remove any patches
	if [ -f patch-stamp ]; then $(MAKE) -f debian/rules unpatch; fi

	# Finally, clean the whole enchilada
	#-$(MAKE) clean -S

	# Debian stuff
	rm -f debian/check.tar debian/local/sensible-mda 
	rm -f debian/local/site.config.m4
	rm -f debian/local/config.* 
	rm -rf debian/tmp debian/$(package)

	# Local approximation of distclean
	for file in \
		mail.local mailstats makemap praliases rmail smrsh src; do \
		rm -rf $$(find . -name "obj*" -type d); \
	done;

	# Cleanup after build (for pristine source, smaller diffs)
	#find .. -name $(package)*.asc -size 0 -maxdepth 1 -exec rm {} ";"

	dh_clean

#-------------
build: build-stamp
build-stamp: setup-stamp
	dh_testdir

	# Add here commands to compile the package.
	#$(MAKE)

	# First, install any patches
	if [ ! -f patch-stamp ]; then $(MAKE) -f debian/rules patch; fi

	# Finally, build the whole enchilada
	cd mail.local && ./Build -f ../debian/local/site.config.m4 \
		LIBS=""
	cd mailstats && ./Build -f ../debian/local/site.config.m4 \
		LIBS=""
	cd makemap && ./Build -f ../debian/local/site.config.m4 \
		LIBS="-ldb" 
	cd praliases && ./Build -f ../debian/local/site.config.m4 \
		LIBS="-ldb"
	cd rmail && ./Build -f ../debian/local/site.config.m4 \
		LIBS=""
	cd smrsh && ./Build -f ../debian/local/site.config.m4 \
		LIBS=""
	cd src && ./Build -f ../debian/local/site.config.m4 \
		LIBS="-ldb -lwrap -lnsl -lresolv"
	#	LIBS="-ldb2 -lwrap -lnsl -lresolv -lldap -llber-openldap"
	#	MAPDEF="-DNEWDB -DMAP_REGEX -DLDAPMAP $(DNIS_DEF)"

	# Debian stuff
	cd debian/local && gcc -O2 -o sensible-mda sensible-mda.c

	# Cleanup after build (for pristine source, smaller diffs)
	# None - Must leave patches to prevent rebuilds

	touch build-stamp

#-------------
install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	#dh_clean -k
	dh_clean

	dh_installdirs

	# Add here commands to install the package into $(TEMP_DIR).
	#$(MAKE) prefix=`pwd`/$(TEMP_DIR)/usr install

	# sendmail install proper... with a little help ;-}
	#$(MAKE) install DESTDIR="$$(pwd)/$(TEMP_DIR)"
	cd mail.local/obj* && $(MAKE) force-install \
		DESTDIR="../../$(TEMP_DIR)"
	cd mailstats/obj* && $(MAKE) install \
		DESTDIR="../../$(TEMP_DIR)"
	cd makemap/obj* && $(MAKE) install \
		DESTDIR="../../$(TEMP_DIR)"
	cd praliases/obj* && $(MAKE) install \
		DESTDIR="../../$(TEMP_DIR)"
	cd rmail/obj* && $(MAKE) force-install \
		DESTDIR="../../$(TEMP_DIR)"
	cd smrsh/obj* && $(MAKE) install \
		DESTDIR="../../$(TEMP_DIR)"
	cd src/obj* && $(MAKE) install \
		DESTDIR="../../$(TEMP_DIR)"
	
	# correct what the m4 build process did...
	mv $(TEMP_DIR)/usr/bin/rmail $(TEMP_DIR)/usr/sbin/rmail
	#ln -sf ../sbin/rmail $(TEMP_DIR)/usr/bin/rmail
	rm -f $(TEMP_DIR)/var/lib/sendmail/sendmail.st
	chown root.mail $(TEMP_DIR)/usr/share/sendmail/sendmail.hf
	# NOTE: whilst smptd is a valid alias for sendmail, we don't create
	# one so that we can co-exists with smtpd (a firewall frontend)
	# NOTE: newscache package also contains /usr/sbin/hoststat
	cd $(TEMP_DIR)/usr/bin && \
		rm -f hoststat mailq newaliases purgestat smtpd
	for file in \
		$(TEMP_DIR)/usr/bin/mailq \
		$(TEMP_DIR)/usr/lib/sendmail; do \
		ln -sf ../sbin/sendmail $$file; \
		done;
	# newalias, purgestat, etc. aren't for the general user...
	# yeah, yeah, I know... these can be done with -bxxx as well!
	cd $(TEMP_DIR)/usr/sbin && for file in \
		newaliases purgestat \
                ; do \
		ln -sf sendmail $$file; \
		done;

	# create some usefull defaults in /usr/lib/sm.bin (for smrsh)
	cd $(TEMP_DIR)/usr/lib/sm.bin && \
		ln -sf ../../bin/procmail procmail && \
		ln -sf ../../bin/deliver deliver && \
		ln -sf ../../bin/vacation vacation

	# sendmail documentation
	install -pm 0444 doc/*/*.ps $(DOC_DIR)/$(package)/
	cd doc && { \
		for doc in \
		    changes/changes intro/intro op/op usenix/usenix; do\
		    base=$$(basename $$doc.txt); \
		    test -f $$doc.txt || \
		    nroff -me $$doc.me | \
		    cat -s > ../$(DOC_DIR)/$(package)/$$base; \
		    done; \
		}

	# m4 configuration directories
	install -pm 0444 cf/README \
		$(DOC_DIR)/$(package)/cf.README
	cp -a cf/* $(TEMP_DIR)/usr/share/$(package)/sendmail.cf
	rm -f $(TEMP_DIR)/usr/share/$(package)/sendmail.cf/README

	# contributed stuff - scripts
	sed "s?/usr/local/bin/perl?/usr/bin/perl?g" contrib/etrn.pl \
		| sed "s?/etc/sendmail.cf?/etc/mail/sendmail.cf?g" \
		> $(TEMP_DIR)/usr/sbin/etrn
	chmod 0755 $(TEMP_DIR)/usr/sbin/etrn
	sed "s?/usr/local/bin/perl?/usr/bin/perl?g" contrib/expn.pl \
		> $(TEMP_DIR)/usr/bin/expn
	chmod 0755 $(TEMP_DIR)/usr/bin/expn
	sed "s?/etc/sendmail.cf?/etc/mail/sendmail.cf?g" \
		debian/checksendmail/checksendmail.perl \
		> $(TEMP_DIR)/usr/sbin/checksendmail
	chmod 0755 $(TEMP_DIR)/usr/sbin/checksendmail
	# contributed stuff - man
	sed "s?/usr/local/bin/perl?/usr/bin/perl?g" contrib/etrn.pl \
		> $(MAN_DIR)/man8/etrn.8
	sed "s?/usr/local/bin/perl?/usr/bin/perl?g" contrib/expn.pl \
		> $(MAN_DIR)/man8/expn.8
	install -p debian/checksendmail/checksendmail.8 \
		$(MAN_DIR)/man8/
	# contributed stuff - examples 
	sed "s?/bin/perl?/usr/bin/perl?g" contrib/passwd-to-alias.pl \
	  > $(DOC_DIR)/$(package)/examples/passwd-to-alias
	chmod 0755 $(DOC_DIR)/$(package)/examples/passwd-to-alias

	# Debian stuff - binaries
	install -pm 0755 debian/local/sendmailconfig $(TEMP_DIR)/usr/sbin
	install -pm 0755 debian/local/runq $(TEMP_DIR)/usr/sbin
	install -pm 0755 debian/local/sensible-mda $(TEMP_DIR)/usr/lib/sm.bin
	# Debian stuff - scripts
	install -pm 0755 debian/local/parsemc $(TEMP_DIR)/usr/share/sendmail
	install -pm 0755 debian/local/updatedb $(TEMP_DIR)/usr/share/sendmail
	install -pm 0755 debian/local/ip-up.d \
		$(TEMP_DIR)/etc/ppp/ip-up.d/sendmail
	install -pm 0755 debian/local/ip-down.d \
		$(TEMP_DIR)/etc/ppp/ip-down.d/sendmail
	# Debian stuff - config files
	install -pm 0660 -g mail debian/local/service.switch* \
		$(TEMP_DIR)/etc/mail/
	# Debian stuff - m4
	cp -a debian/cf/* $(TEMP_DIR)/usr/share/$(package)/sendmail.cf
	install -pm 0660 -g mail debian/local/provider \
		$(TEMP_DIR)/etc/mail/peers/provider

	#$(MAKE) -f debian/rules hacks
	
	# Not quite debhelper v2 compliant yet
	#dh_movefiles 

	# Cleanup after build (for pristine source, smaller diffs)
	$(MAKE) -f debian/rules unpatch

	touch install-stamp

#-------------
# This single target is used to build all the packages, all at once, or
# one at a time. So keep in mind: any options passed to commands here will
# affect _all_ packages. Anything you want to only affect one package
# should be put in another target, such as the install target.
binary-common:
	# Need this version of debhelper for DH_OPTIONS to work.
	dh_testversion 1.1.17
	dh_testdir
	dh_testroot
	dh_installchangelogs -k RELEASE_NOTES
	dh_installcron
	if [ -x /usr/bin/dh_installdebconf ]; then dh_installdebconf; fi
	dh_installdocs debian/Debian-specific 
	dh_installemacsen
	dh_installexamples
	  chmod 0755 $(DOC_DIR)/$(package)/examples/passwd-to-alias
	  chmod 0755 $(DOC_DIR)/$(package)/examples/ip-up.d
	  chmod 0755 $(DOC_DIR)/$(package)/examples/ip-down.d
	if [ -x /usr/bin/dh_installinfo ]; then dh_installinfo; fi
	dh_installinit
	#   install $(TEMP_DIR).init.d $(TEMP_DIR)/etc/init.d/sendmail
	dh_installmanpages
	cd $(MAN_DIR)/man8 && \
		ln -sf sendmail.8.gz ./purgestat.8.gz 
	#	ln -sf sendmail.8.gz ./hoststat.8.gz
	#	ln -sf sendmail.8.gz ./sendmail.real.8.gz
	sed "s?/usr/adm/sm.bin?/usr/lib/sm.bin?g" smrsh/smrsh.8 \
		> $(MAN_DIR)/man8/smrsh.8
	dh_undocumented
	dh_installmenu
	if [ -x /usr/bin/dh_installpam ]; then dh_installpam; fi
	#
	$(MAKE) -s -f debian/rules buildinfo
	#
	if [ -x /usr/bin/dh_link ]; then dh_link; fi
	dh_strip
	dh_compress
	dh_fixperms
	#
	# Cleanup misc permissions, etc... (fakeroot, etc.)
	chmod    a+x $(TEMP_DIR)/usr/share/sendmail/sendmail.cf/sh/*
	#
	# You may want to make some executables suid here.
	chmod 04755 $(TEMP_DIR)/usr/sbin/sendmail
	chown 0.8   $(TEMP_DIR)/usr/sbin/sendmail
	chmod 0755  $(TEMP_DIR)/usr/sbin/mailstats
	chown 0.8   $(TEMP_DIR)/usr/sbin/mailstats
	chmod 04755 $(TEMP_DIR)/usr/lib/sm.bin/mail.local
	chown 0.8   $(TEMP_DIR)/usr/lib/sm.bin/mail.local
	chmod 0755  $(TEMP_DIR)/usr/lib/sm.bin/smrsh
	chown 0.8   $(TEMP_DIR)/usr/lib/sm.bin/smrsh
	chmod 0755  $(TEMP_DIR)/usr/lib/sm.bin/sensible-mda
	chown 0.8   $(TEMP_DIR)/usr/lib/sm.bin/sensible-mda
	#
	dh_suidregister
	dh_makeshlibs
	dh_installdeb
	#
	# Can now clean up debian/*.debhelper scripts
	rm -f debian/*.debhelper
	dh_shlibdeps
	# Handle perl specially, to support building under slink
	if [ -x /usr/bin/dh_perl ]; then \
		dh_perl; \
	else \
		echo "perl:Depends=perl5" >> debian/substvars; \
		fi
	dh_gencontrol
	dh_md5sums -x
	dh_builddeb

#-------------
# Build architecture independant packages using the common target.
# (Uncomment this next line if you have such packages.)
#binary-indep: build install
#	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common

#-------------
# Build architecture dependant packages using the common target.
binary-arch: build install
	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common

#-------------
# Any other binary targets build just one binary package at a time.
binary-%: build install
        make -f debian/rules binary-common DH_OPTIONS=-p$*

#-------------
l33ch:
	dh_testdir
	#@echo >&2 'l33ch is obsolete'; false
	cd debian && \
		wget --passive-ftp --timestamping \
		http://www.sendmail.org/faq/faq.txt
	#ftp://rtfm.mit.edu/pub/usenet/comp.mail.sendmail/sendmail_FAQ
                                                                                
#-------------
patch: patch-stamp
patch-stamp:
	dh_testdir

	$(MAKE) -s -f debian/patches/Makefile patch

	touch patch-stamp

unpatch: unpatch-stamp
unpatch-stamp: patch-stamp
	dh_testdir

	$(MAKE) -s -f debian/patches/Makefile unpatch

	rm -f patch-stamp

#-------------
hacks:
#	cd debian && uudecode check.tar.uue
#	cd $(DOC_DIR)/$(package) && tar -xf ../../../../check.tar
#	cd $(DOC_DIR)/$(package)/hack; \
#	for file in *; do \
#		sed "s/dbm /hash /g" < $$file \
#			> ../../../share/sendmail.cf/hack/$$file; \
#		done
#	sed "s/dbm /hash /g" $(DOC_DIR)/$(package)/README.check \
#		> $(DOC_DIR)/$(package)/README.Spam
#	rm $(DOC_DIR)/$(package)/README.check
#	rm -r $(DOC_DIR)/$(package)/hack/

#-------------
buildinfo:
	@echo; dpkg -l gcc "libc6*" binutils ldso make libdb2 libdb2.6 \
			libopenldap1 dpkg-dev $(BUILDINFO) \
		| awk '$$1 == "ii" { printf("%s-%s\n", $$2, $$3) }' \
		| tee $(DOC_DIR)/$(package)/buildinfo.Debian; echo
	chmod 644 $(DOC_DIR)/$(package)/buildinfo.Debian		

#-------------
# Below here is fairly generic really

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install