summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 3c4ae95b5b2ecb3e029aca3f0b195d58504fd6f9 (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
#!/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>
# modified for Postfix by LaMont Jones <lamont@debian.org>

PACKAGE=postfix
DISTRO:=$(shell (lsb_release -is 2>/dev/null || echo Debian) | sed s:Debian:Debian/GNU:)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

package=postfix
base=debian/$(package)
docpkg=${package}-doc
exampledir=${base}-doc/usr/share/doc/${package}-doc
docdir=${base}-doc/usr/share/doc/$(package)
chlogdir=${base}/usr/share/doc/$(package)
sharedir=${base}/usr/share/postfix
libdir=${base}/usr/lib/postfix
plibdir=usr/lib/postfix
sbindir=usr/sbin
bindir=${base}/usr/bin
confdir=${base}/etc/postfix

#ifeq ($(DEB_BUILD_ARCH),sparc)
#  OFLAGS = -O1
#else
#  OFLAGS = -O1
#endif

OFLAGS += -O2
SHELL=/bin/bash

DEBUG += -g
ifneq (,$(findstring nodebug,$(DEB_BUILD_OPTIONS)))
DEBUG = ''
endif

ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
STRIP=y
endif

CCARGS += -DDEBIAN -DHAS_PCRE -DHAS_LDAP -DUSE_LDAP_SASL \
	-DHAS_SQLITE -DMYORIGIN_FROM_FILE \
	$(shell getconf LFS_CFLAGS) \
	-DHAS_CDB \
	-DHAS_LMDB \
	-DHAS_MYSQL -I/usr/include/mysql \
	-DHAS_PGSQL -I`pg_config --includedir` \
	-DHAS_SQLITE -I/usr/include \
	-DHAS_SSL -I/usr/include/openssl \
	-DUSE_SASL_AUTH -I/usr/include/sasl \
	-DUSE_CYRUS_SASL \
	-DUSE_TLS

AUXLIBS += -lssl -lcrypto -lsasl2 -lpthread

DOCFILES=README_FILES/*_README README_FILES/OVERVIEW COMPATIBILITY PORTING
TLSDOCFILES=${TLSSRC}/TLS_TODO ${TLSSRC}/TLS_ACKNOWLEDGEMENTS

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

build: build-arch build-indep
build-arch:
	$(checkdir)
	${MAKE} makefiles CCARGS="${CCARGS}" DEBUG="${DEBUG}" \
		AUXLIBS="${AUXLIBS} -L$$(pwd)/debian" OPT="$(OFLAGS)" \
		AUXLIBS_CDB="-lcdb -L../../lib -L. -lpostfix-util" \
		AUXLIBS_LDAP="-lldap -llber -L../../lib -L. -lpostfix-util -lpostfix-global" \
		AUXLIBS_LMDB="-llmdb -L../../lib -L. -lpostfix-util" \
		AUXLIBS_MYSQL="-lmysqlclient -L../../lib -L. -lpostfix-util -lpostfix-global" \
		AUXLIBS_PCRE="-lpcre -L../../lib -L. -lpostfix-util" \
		AUXLIBS_PGSQL="-lpq -L../../lib -L. -lpostfix-util -lpostfix-global" \
		AUXLIBS_SQLITE="-lsqlite3 -L../../lib -L. -lpostfix-util -lpostfix-global -lpthread" \
		shared=yes pie=yes dynamicmaps=yes \
		daemon_directory=${CUR_DIR}/usr/lib/postfix/sbin \
		shlibs_directory=${CUR_DIR}/usr/lib/postfix manpage_directory=/usr/share/man \
		sample_directory=/usr/share/doc/postfix/examples readme_directory=/usr/share/doc/postfix \
		html_directory=/usr/share/doc/postfix/html
	${MAKE} LD_LIBRARY_PATH=$$(pwd)/lib:$${LD_LIBRARY_PATH}
	${MAKE} manpages
	sed "s:@@DISTRO@@:$(DISTRO):g" < debian/main.cf.in > conf/main.cf.debian
	sed "s:@@DISTRO@@:$(DISTRO):g" < conf/main.cf > conf/main.cf.dist
	touch build

build-indep:
	$(checkdir)
	${MAKE} makefiles CCARGS="${CCARGS}" DEBUG="${DEBUG}" \
		AUXLIBS="${AUXLIBS} -L$$(pwd)/debian" OPT="$(OFLAGS)" \
		AUXLIBS_CDB="-lcdb -L../../lib -L. -lpostfix-util" \
		AUXLIBS_LDAP="-lldap -llber -L../../lib -L. -lpostfix-util -lpostfix-global" \
		AUXLIBS_LMDB="-llmdb -L../../lib -L. -lpostfix-util" \
		AUXLIBS_MYSQL="-lmysqlclient -L../../lib -L. -lpostfix-util -lpostfix-global" \
		AUXLIBS_PCRE="-lpcre -L../../lib -L. -lpostfix-util" \
		AUXLIBS_PGSQL="-lpq -L../../lib -L. -lpostfix-util -lpostfix-global" \
		AUXLIBS_SQLITE="-lsqlite3 -L../../lib -L. -lpostfix-util -lpostfix-global -lpthread" \
		shared=yes pie=yes dynamicmaps=yes \
		daemon_directory=${CUR_DIR}/usr/lib/postfix/sbin \
		shlibs_directory=${CUR_DIR}/usr/lib/postfix manpage_directory=/usr/share/man \
		sample_directory=/usr/share/doc/postfix/examples readme_directory=/usr/share/doc/postfix \
		html_directory=/usr/share/doc/postfix/html
	${MAKE} LD_LIBRARY_PATH=$$(pwd)/lib:$${LD_LIBRARY_PATH}
	${MAKE} manpages
	sed "s:@@DISTRO@@:$(DISTRO):g" < debian/main.cf.in > conf/main.cf.debian
	sed "s:@@DISTRO@@:$(DISTRO):g" < conf/main.cf > conf/main.cf.dist
	touch build

install-indep: build-indep
	dh_prep
	dh_installdirs -i
	install -m 0444 html/* $(docdir)/html; rm $(docdir)/html/Makefile.in
	dh_installexamples -p ${docpkg} examples/{qmail-local,smtpd-policy}
	dh_installexamples -p ${docpkg} -Xmain.cf -Xmaster.cf -Xfiles conf/[a-z]*
	dh_installexamples -p ${docpkg} conf/main.cf.default debian/mailqfmt.pl
	mv ${exampledir}/examples ${docdir}
	install -m 0444 RELEASE_NOTES $(docdir)/RELEASE_NOTES
	install -m 0444 AAAREADME $(docdir)/README
	for file in */README; do \
	    install -m 0444 $${file} $(docdir)/README.$${file%/README}; \
	done
	if [ ! -f meta/doc.files ] ; then \
		cd meta && for i in sample readme html ; do \
			grep $${i} postfix-files >> doc.files ; \
		done \
	fi
	rm -f $(docdir)/README.mantools
	for file in ${DOCFILES}; do					\
		install -m 0444 $${file} $(docdir)/$${file##*/};	\
	done
	rm -f $(docdir)/ULTRIX_README $(docdir)/MACOSX_README
	cd meta && for h in ULTRIX MACOSX mantools ; do \
		grep -v $${h} doc.files > doc.files.$$ ; \
		mv doc.files.$$ doc.files ; \
	done
	mkdir -m 755 -p $(base)-doc/etc/postfix/postfix-files.d 
	install -m 644 meta/doc.files ${base}-doc/etc/postfix/postfix-files.d

install-arch: build-arch
	dh_prep
	dh_installdirs -a
	install lib/lib* $(libdir)
	install debian/postfix_groups.pl $(libdir)
	install -m 0644 meta/postfix-files $(confdir)
	cd $(confdir) && for i in sample readme html LICENSE ; do \
		grep -v $${i} postfix-files > postfix-files.$$ ; \
		mv postfix-files.$$ postfix-files ; \
	done
	for j in cdb ldap lmdb mysql pcre pgsql sqlite ; do \
		mkdir -m 755 -p $(base)-$${j}/etc/postfix/postfix-files.d ; \
		grep $${j} $(confdir)/postfix-files >> $(base)-$${j}/etc/postfix/postfix-files.d/$${j}.files ; \
		grep -v $${j} $(confdir)/postfix-files > $(confdir)/postfix-files.$$ ; \
			mv $(confdir)/postfix-files.$$ $(confdir)/postfix-files ; \
		install lib/postfix-$${j}.so ${base}-$${j}/${plibdir} ; \
		ln -s postfix-$${j}.so ${base}-$${j}/${plibdir}/postfix-$${j}.so.1.0.1 ; \
	done
	install libexec/[a-z]* ${base}/${plibdir}/sbin
	install bin/[a-z]* ${base}/${sbindir}
	# See conf/postfix-files
	ln ${libdir}/sbin/smtp ${libdir}/sbin//lmtp
	ln ${libdir}/sbin/qmgr ${libdir}/sbin/nqmgr
	install debian/postfix-add-filter ${base}/${sbindir}
	install debian/postfix-add-policy ${base}/${sbindir}
	install auxiliary/qshape/qshape.pl ${base}/${sbindir}/qshape
	install -m 0444 HISTORY $(chlogdir)/changelog
	ln -s ../sbin/rmail $(bindir)/rmail
	ln -s ../sbin/sendmail $(bindir)/newaliases
	ln -s ../sbin/sendmail $(bindir)/mailq
	ln -s ../sbin/sendmail ${base}/usr/lib/sendmail
	install -m 0755 conf/postfix-script conf/post-install $(confdir)
	install -m 0644 conf/makedefs.out $(sharedir)
	install -m 0644 debian/functions $(sharedir)/postinst.functions
	install -m 0644 conf/master.cf $(sharedir)/master.cf.dist
	install -m 0644 conf/main.cf.dist $(sharedir)/main.cf.dist
	install -m 0644 conf/main.cf.debian $(sharedir)/main.cf.debian
	install -m 0644 conf/main.cf.tls $(sharedir)/main.cf.tls
	install -m 0644 meta/dynamicmaps.cf $(sharedir)/dynamicmaps.cf
	install -m644 debian/postfix.ufw.profile debian/postfix/etc/ufw/applications.d/postfix
	install -m644 debian/rsyslog.conf debian/postfix/etc/rsyslog.d/postfix.conf
	install -m644 debian/postfix.insserv.conf debian/postfix/etc/insserv.conf.d/postfix

	install man/man1/*.1 ${base}/usr/share/man/man1
	install man/man5/*.5 ${base}/usr/share/man/man5
	for j in ldap lmdb mysql pcre pgsql sqlite ; do \
		mkdir -m 755 -p $(base)-$${j}/usr/share/man/man5 ; \
		mv ${base}/usr/share/man/man5/$${j}_table.5 ${base}-$${j}/usr/share/man/man5 ; \
        done

	for f in man/man8/*.8; do \
	  sed '/^\.TH/s/ 8 / 8postfix /' $${f}>${base}/usr/share/$${f}postfix; \
	  chmod 644 ${base}/usr/share/$${f}postfix; \
	  chown root:root ${base}/usr/share/$${f}postfix; \
	done
	install rmail/rmail.8 debian/*.8 ${base}/usr/share/man/man8
	gzip -9n ${base}/usr/share/man/man8/*.8postfix
	ln -sf bounce.8postfix.gz ${base}/usr/share/man/man8/trace.8postfix.gz
	ln -sf bounce.8postfix.gz ${base}/usr/share/man/man8/defer.8postfix.gz

	install debian/configure-instance.sh $(libdir)
	install debian/postfix-instance-generator ${base}/lib/systemd/system-generators/
	install -m 644 debian/postfix@.service ${base}/lib/systemd/system/
	install debian/ip-up.d ${base}/etc/ppp/ip-up.d/postfix
	install debian/ip-down.d ${base}/etc/ppp/ip-down.d/postfix
	install debian/ip-up.d ${base}/etc/network/if-up.d/postfix
	install debian/ip-down.d ${base}/etc/network/if-down.d/postfix
	install debian/update-libc.d ${base}/etc/resolvconf/update-libc.d/postfix
	install debian/postfix-cdb.lintian-override ${base}-cdb/usr/share/lintian/overrides/${package}-cdb
	install debian/postfix-ldap.lintian-override ${base}-ldap/usr/share/lintian/overrides/${package}-ldap
	install debian/postfix-lmdb.lintian-override ${base}-lmdb/usr/share/lintian/overrides/${package}-lmdb
	install debian/postfix.lintian-override ${base}/usr/share/lintian/overrides/${package}
	install debian/postfix-mysql.lintian-override ${base}-mysql/usr/share/lintian/overrides/${package}-mysql
	install debian/postfix-pcre.lintian-override ${base}-pcre/usr/share/lintian/overrides/${package}-pcre
	install debian/postfix-pgsql.lintian-override ${base}-pgsql/usr/share/lintian/overrides/${package}-pgsql

	if dpkg-vendor --is ubuntu; then \
	    install -m 644 -D debian/postfix.apport ${base}/usr/share/apport/package-hooks/postfix.py; \
	fi

debian/vars:
	cp debian/vars.in $@
	# This assumes non-native, and at least one hyphen in the version number.
	echo Upstream=$$(sed 's/^.*(\(.*\)-[^-]*).*/\1/; q' debian/changelog) >> $@

binary-indep: checkroot install-indep debian/vars
	dh_installdocs -i
##	dh_installexamples -i
##	dh_installmenu -i
##	dh_installcron -i
	dh_installchangelogs -i
	dh_installdebconf -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	for i in $$(sed -n '/^Package:/s/^.* //p' debian/control); do cat debian/vars >> debian/$$i.substvars; done
	cat debian/vars.in >> debian/substvars
	dh_gencontrol -i
##	dh_makeshlibs -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: checkroot install-arch debian/vars

	dh_installdocs -a
##	dh_installexamples -a
##	dh_installmenu -a
##	dh_installcron -a
	dh_installchangelogs -a
	dh_installdebconf -a
	dh_systemd_enable -a
	dh_installinit -a
	dh_systemd_start -a
##	dh_movefiles -a
	[ -n "$(STRIP)" ] || dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a
	dh_installdeb -a
	LD_LIBRARY_PATH=$$(pwd)/lib:$${LD_LIBRARY_PATH} dh_shlibdeps -a
	for i in $$(sed -n '/^Package:/s/^.* //p' debian/control); do cat debian/vars >> debian/$$i.substvars; done
	cat debian/vars.in >> debian/substvars
	if [ $(DISTRO) = Ubuntu ]; then echo postfix:Provides=default-mta >> debian/postfix.substvars; fi
	dh_gencontrol -a
##	dh_makeshlibs -a
	dh_md5sums -a
	dh_builddeb -a

clean-preunpatch:
	$(checkdir)
	dh_clean build
	test ! -d ${base} || rm -rf ${base}
	$(MAKE) tidy

clean: clean-preunpatch
	rm -rf debian/{files*,vars,*substvars,*.debhelper}
	find .. -maxdepth 1 -name $(package)*.asc -size 0 -exec rm {} ";"
	rm -f debian/stamp-* conf/main.cf.debian conf/main.cf.dist meta/doc.files

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

define checkdir
	test -f debian/rules
endef

# Below here is fairly generic really

binary: binary-arch binary-indep

newtemplate:
	debconf-updatepo

msgstats:
	@cd debian/po && for i in *.po; do x=$$(msgfmt --statistics $$i 2>&1); echo $$i $$x; done; rm -f messages.mo *.po~

msg-email:
	@podebconf-report-po

checkroot:
	$(checkdir)
	test "`id -u`" -eq 0