summaryrefslogtreecommitdiff
path: root/debian/rules
blob: c5eecb3f9c4592ded87235ce3c9d8b3c536aca74 (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
#!/usr/bin/make -f
# -*- makefile -*- 
# Debianrules for building a Debian package
# Version 1.5
#
# These rules have been specifically designed NOT to require root to
# run them. At any time root privileges are required, the command to be
# executed will be made obvious and root's password will be prompted for.
# Of course, root may still run this and no password will be required.
#
# Robert Leslie <rob@mars.org>

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

LIBS = -ldb -lresolv -lnsl -lwrap
DBMDEF = -DNEWDB -DNIS
ENVDEF = -DHASFLOCK=1 -DTCPWRAPPERS=1 -include $(shell pwd)/debian/el33t.h \
	-I/usr/include/db

CC=cc
GCC = $(CC) $(HACK)
OFLAGS = -O2
SHELL=/bin/bash


.SILENT: rmail/rmail

rmail/rmail:
	cd rmail && $(GCC) $(OFLAGS) rmail.c -o rmail



.PHONY: man bin

build:
	$(checkdir)
#	-ln -sf /usr/include/gdbm-ndbm.h src/ndbm.h
	cd src && ./makesendmail sendmail \
		CC="$(GCC)" O="$(OFLAGS)" DBMDEF="$(DBMDEF)" \
		ENVDEF="$(ENVDEF)" INCDIRS="$(INCDIRS)" \
		LIBS="$(LIBS)" LIBDIRS=""
	$(MAKE) -C mailstats -f Makefile.dist mailstats \
		CC="$(GCC)" O="$(OFLAGS)" \
		INCDIRS="-I../src" LIBDIRS=""
	$(MAKE) -C makemap -f Makefile.dist makemap \
		CC="$(GCC)" O="$(OFLAGS)" \
		INCDIRS="-I../src -I/usr/include/db" \
		LIBDIRS="" LIBS="$(LIBS)" DBMDEF="$(DBMDEF)"
	$(MAKE) -C praliases -f Makefile.dist praliases \
		CC="$(GCC)" O="$(OFLAGS)" \
		INCDIRS="-I../src -I/usr/include/db" \
		LIBDIRS="" LIBS="$(LIBS)"
#	-$(MAKE) -C mail.local -f Makefile.dist mail.local \
#		CC="$(GCC)" O="$(OFLAGS)" INCDIRS="-I../src" \
#		LIBDIRS="" LIBS="" ENVDEF="-DBSD4_4"
	$(MAKE) -C smrsh  -f Makefile.dist smrsh \
		CC="$(GCC)" O="$(OFLAGS)" \
		ENVDEF="-DCMDDIR=\\\"/usr/lib/sm.bin\\\" \
			-DPATH=\\\"/usr/bin:/bin\\\"" \
		INCDIRS="-I../src" LIBDIRS=""
	$(MAKE) -f debian/rules rmail/rmail
	cd doc && { \
	    for doc in changes/changes intro/intro op/op usenix/usenix; \
	    do test -f $$doc.txt || \
	      nroff -me $$doc.me | cat -s > $$doc.txt; done; \
	}
	test -f debian/part1 && test -f debian/part2
	cd debian && gcc -o sensible-mda sensible-mda.c
	touch build


l33ch:
	cd debian && \
	wget ftp://rtfm.mit.edu/pub/usenet/news.answers/mail/sendmail-faq/part1
	cd debian && \
	wget ftp://rtfm.mit.edu/pub/usenet/news.answers/mail/sendmail-faq/part2


man:
	cp -p debian/runq.1 debian/tmp/usr/man/man1
	cp -p debian/sendmailconfig.8 debian/tmp/usr/man/man8
	cp -p debian/sensible-mda.8 debian/tmp/usr/man/man8
	for file in src/*.[158] mailstats/*.8 makemap/*.8 \
		praliases/*.8 smrsh/*.8 rmail/*.8; do \
	    base=$$(basename $$file); \
	    ext=$$(echo $$file | sed -e "s/.*\(.\)$$/\1/"); \
	    sed -e "s#/usr/adm/sm.bin#/usr/lib/sm.bin#g" \
		-e "s#/etc/sendmail.hf#/usr/lib/sendmail.hf#g" \
		-e "s#/bin:/usr/bin:/usr/ucb#/usr/bin:/bin#g" \
		-e "s#/etc/rc#/etc/init.d/sendmail#g" $$file \
		> debian/tmp/usr/man/man$$ext/$$base; \
	done
	install -m 644 contrib/etrn.pl debian/tmp/usr/man/man8/etrn.8
	install -m 644 contrib/expn.pl debian/tmp/usr/man/man8/expn.8
	cp -p checksendmail/address.resolve debian/tmp/usr/doc/$(package)
	cp -p checksendmail/checksendmail.8 debian/tmp/usr/man/man8


bin:
	install rmail/rmail debian/tmp/usr/bin
	cd src && ./makesendmail install-sendmail \
		DESTDIR="$$(pwd)/../debian/tmp" BINGRP="root"
		STDIR="$$(pwd)/../debian/tmp/var/log"
#	cd debian/tmp && mv etc/sendmail.hf usr/lib
	rm -f debian/tmp/etc/sendmail.st
	$(MAKE) -s -C mailstats -f Makefile.dist install-mailstats \
		DESTDIR="../debian/tmp"
	$(MAKE) -s -C makemap -f Makefile.dist install-makemap \
		DESTDIR="../debian/tmp"
	$(MAKE) -s -C praliases -f Makefile.dist install-praliases \
		DESTDIR="../debian/tmp"
	$(MAKE) -s -C smrsh -f Makefile.dist install-smrsh \
		BINDIR="../debian/tmp/usr/sbin"
#	-$(MAKE) -s -C mail.local -f Makefile.dist install-mail.local \
#		BINDIR="../debian/tmp/usr/sbin"
	strip --strip-debug debian/tmp/usr/{bin,sbin}/*
	install debian/sendmailconfig debian/sensible-mda debian/tmp/usr/sbin
	install debian/runq debian/tmp/usr/bin
	sed "s?/usr/local/bin/perl?/usr/bin/perl?g" contrib/etrn.pl \
		> debian/tmp/usr/sbin/etrn
	sed "s?/usr/local/bin/perl?/usr/bin/perl?g" contrib/expn.pl \
		> debian/tmp/usr/bin/expn
	chmod 755 debian/tmp/usr/sbin/etrn debian/tmp/usr/bin/expn
	install checksendmail/checksendmail.perl debian/tmp/usr/sbin/checksendmail
	for file in debian/tmp/usr/bin/{hoststat,mailq,newaliases,purgestat} \
	    debian/tmp/usr/lib/sendmail; do \
	    rm -f $$file && ln -s ../sbin/sendmail $$file; \
	done



hacks:
	cd debian && uudecode check.tar.uue
	cd debian/tmp/usr/doc/$(package) && tar -xf ../../../../check.tar
	cd debian/tmp/usr/doc/$(package)/hack; \
	    for file in *; do \
		sed "s/dbm /hash /g" < $$file \
			> ../../../lib/sendmail.cf/hack/$$file; \
	done
	sed "s/dbm /hash /g" debian/tmp/usr/doc/$(package)/README.check \
		> debian/tmp/usr/doc/$(package)/README.Spam
	rm debian/tmp/usr/doc/$(package)/README.check
	rm -r debian/tmp/usr/doc/$(package)/hack/
	cp -p debian/{rbl*,nodns}.m4 debian/tmp/usr/lib/sendmail.cf/hack


binary-indep: checkroot
	$(checkdir)

binary-arch: checkroot build
	$(checkdir)
	rm -rf debian/tmp && install -d debian/tmp
	cd debian/tmp && install -d $$(cat ../dirs)
	cp debian/{conffiles,control} debian/tmp/DEBIAN
	install debian/{pre*,post*} debian/tmp/DEBIAN

	$(MAKE) -f debian/rules man
	cp -p doc/*/{*.ps,*.txt} debian/tmp/usr/doc/$(package)
	cp -p RELEASE_NOTES debian/tmp/usr/doc/$(package)/changelog
#	cp -p debian/changelog \
#		debian/tmp/usr/doc/$(package)/changelog.Debian
	cp -p cf/README debian/tmp/usr/doc/$(package)/cf.README
	cp -p debian/part1 debian/tmp/usr/doc/$(package)/FAQ-1.txt
	cp -p debian/part2 debian/tmp/usr/doc/$(package)/FAQ-2.txt
	find debian/tmp/usr/doc/$(package) debian/tmp/usr/man \
		-type f -exec gzip -v9 {} ";"
	cd debian/tmp/usr/man/man8 && \
	        ln -s sendmail.8.gz ./purgestat.8.gz && \
        	ln -s sendmail.8.gz ./hoststat.8.gz
	cp -p debian/{README*,copyright} contrib/passwd-to-alias.pl \
		KNOWNBUGS debian/tmp/usr/doc/$(package)
	chmod a-x debian/tmp/usr/doc/$(package)/passwd-to-alias.pl
	cp debian/debproto.mc debian/tmp/usr/lib/sendmail.cf/cf
	cp -p debian/debian.m4 cf/ostype/* \
		debian/tmp/usr/lib/sendmail.cf/ostype
	cp -p cf/domain/* debian/tmp/usr/lib/sendmail.cf/domain
	cp -a cf/{feature,m4,mailer,sh} debian/tmp/usr/lib/sendmail.cf

	$(MAKE) -f debian/rules bin
	$(MAKE) -f debian/rules hacks
	install debian/init.d debian/tmp/etc/init.d/$(package)
	#install -m 755 debian/ip-up.d debian/tmp/etc/ppp/ip-up.d/$(package)
	#install -m 755 debian/ip-down.d debian/tmp/etc/ppp/ip-down.d/$(package)
	cp -p debian/{aliases,nssnodns.conf} debian/tmp/etc

	chmod -R u=rwX,go=rX debian/tmp
	chown -R root.root debian/tmp
	chmod 4755 debian/tmp/usr/sbin/sendmail
	chmod 700 debian/tmp/var/state/sendmail
	$(MAKE) -s -f debian/rules buildinfo

#	dh_installdocs 
#	dh_installexamples
#	dh_installmenu
#	dh_installcron
#	dh_installmanpages 
	dh_installchangelogs 
#	dh_movefiles 
	dh_strip 
#	dh_compress 
	dh_fixperms 
	dh_suidregister
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol 
#	dh_makeshlibs 
	dh_md5sums 
	dh_builddeb 


clean:
	$(checkdir)
	rm -f build
	test ! -d debian/tmp || rm -rf debian/tmp
	$(MAKE) -C smrsh -f Makefile.dist clean
	$(MAKE) -C praliases -f Makefile.dist clean
	$(MAKE) -C makemap -f Makefile.dist clean
	$(MAKE) -C mailstats -f Makefile.dist clean
	$(MAKE) -C mail.local -f Makefile.dist clean
	rm -f doc/{changes/changes,intro/intro,op/op,usenix/usenix}.txt
	rm -rf rmail/rmail stamp-build $$(find . -name "*~") src/obj.*
	rm -rf $$(find debian/* -type d) $$(find src makemap -type l) 
	rm -rf debian/{files*,*substvars*} debian/{check.tar,sensible-mda} 
	find .. -name $(package)*.asc -size 0 -maxdepth 1 -exec rm {} ";"
	chmod +x debian/{pre*,post*,runq,sendmailconfig}


buildinfo:
	@echo; dpkg -l gcc "libc6*" binutils ldso make dpkg-dev $(BUILDINFO) \
		| awk '$$1 == "ii" { printf("%s-%s\n", $$2, $$3) }' \
		| tee debian/tmp/usr/doc/$(package)/buildinfo.Debian; echo
	chmod 644 debian/tmp/usr/doc/$(package)/buildinfo.Debian		
#	cd debian/tmp && md5sum $$(find * -type f -not -regex "DEBIAN/.*") \
#		> DEBIAN/md5sums
#	rm -f debian/tmp/files.sig
#	-cd debian/tmp && pgp -sat +clearsig=on DEBIAN/md5sums -o files.sig \
#		&& chmod 644 files.sig \
#	 	&& mv -v files.sig usr/doc/$(package)/checksums.txt


define checkdir
	test -f debian/rules
endef

# Below here is fairly generic really

binary: binary-indep binary-arch

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

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean checkroot