summaryrefslogtreecommitdiff
path: root/mail/qmail/Makefile
blob: 90e7efd50d7f7efaf7417a3cee4b93e6cbab4c68 (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
# $NetBSD: Makefile,v 1.108 2019/01/09 19:32:07 schmonz Exp $
#

DISTNAME=		netqmail-1.06
PKGNAME=		qmail-1.03
PKGREVISION=		43
CATEGORIES=		mail
MASTER_SITES=		http://qmail.org/

MAINTAINER=		schmonz@NetBSD.org
HOMEPAGE=		http://qmail.org/netqmail/
COMMENT=		Secure, reliable, efficient, simple, and fast MTA
LICENSE=		public-domain

DEPENDS+=		daemontools-[0-9]*:../../sysutils/daemontools
DEPENDS_LIBTAI=		libtai>=0.60nb5:../../devel/libtai
DEPENDS+=		${DEPENDS_LIBTAI}

CONFLICTS+=		courier-maildirmake-[0-9]*
CONFLICTS+=		courier-mta-[0-9]*
CONFLICTS+=		mirrordir-[0-9]*
CONFLICTS+=		mutt<=1.4.2.1nb1
CONFLICTS+=		netqmail-[0-9]*
CONFLICTS+=		pulsar<=0.1.1
CONFLICTS+=		qmail-run<=20170706

WRKSRC=			${WRKDIR}/${DISTNAME}

DJB_CONFIG_CMDS=	${ECHO} ${DESTDIR:Q}${QMAILDIR:Q} > conf-destdir;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_ALIAS_USER:Q}     > conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_DAEMON_USER:Q}   >> conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_LOG_USER:Q}      >> conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_ROOT_USER:Q}     >> conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_PASSWD_USER:Q}   >> conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_QUEUE_USER:Q}    >> conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_REMOTE_USER:Q}   >> conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_SEND_USER:Q}     >> conf-users;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_QMAIL_GROUP:Q}    > conf-groups;
DJB_CONFIG_CMDS+=	${ECHO} ${QMAIL_NOFILES_GROUP:Q} >> conf-groups;
DJB_BUILD_TARGETS=	man
INSTALL_TARGET=		setup
DJB_RESTRICTED=		no

CFLAGS.Darwin+=		-DBIND_8_COMPAT=1

PKG_SYSCONFSUBDIR=	qmail
OWN_DIRS+=		${PKG_SYSCONFDIR} ${PKG_SYSCONFDIR}/alias
OWN_DIRS+=		${PKG_SYSCONFDIR}/control ${PKG_SYSCONFDIR}/users
OWN_DIRS+=		${PKG_SYSCONFDIR}/.pkgsrc-defaults-do-not-edit
OWN_DIRS+=		${QMAILDIR} ${QMAIL_QUEUE_DIR}

DOCDIR=			${PREFIX}/share/doc/qmail
EGDIR=			${PREFIX}/share/examples/qmail
SHAREDIR=		${PREFIX}/share/qmail
MESSAGE_SRC+=		${PKGDIR}/MESSAGE
MESSAGE_SUBST+=		DOCDIR=${DOCDIR:Q} EGDIR=${EGDIR:Q}
FILES_SUBST+=		DOCDIR=${DOCDIR:Q} EGDIR=${EGDIR:Q}
FILES_SUBST+=		PKGMANDIR=${PKGMANDIR:Q} SHAREDIR=${SHAREDIR:Q}
FILES_SUBST+=		QMAILDIR=${QMAILDIR:Q}
FILES_SUBST+=		QMAIL_DAEMON_USER=${QMAIL_DAEMON_USER:Q}
FILES_SUBST+=		QMAIL_QMAIL_GROUP=${QMAIL_QMAIL_GROUP:Q}
FILES_SUBST+=		QMAIL_QUEUE_DIR=${QMAIL_QUEUE_DIR:Q}
FILES_SUBST+=		QMAIL_QUEUE_EXTRA=${QMAIL_QUEUE_EXTRA:Q}
FILES_SUBST+=		PKGNAME=${PKGNAME:Q}
FILES_SUBST+=		WC=${WC:Q}

SETUP_PROGRAMS=		dnsfq dnsip dnsptr hostname ipmeprint
SETUP_PROGRAMS+=	install-destdir instcheck
SETUP_SCRIPTS=		config config-fast config-fast-pkgsrc

MANDIRS=		man
.for j in 1 5 7 8
MANDIRS+=		man/man${j}
.endfor
INSTALLATION_DIRS=	bin ${MANDIRS} ${DOCDIR} ${SHAREDIR}
INSTALLATION_DIRS+=	${EGDIR}/alias ${EGDIR}/boot ${EGDIR}/control
INSTALLATION_DIRS+=	${EGDIR}/users

.include "../../mk/bsd.prefs.mk"

# Detect the PKG_SYSCONFDIR of the installed libtai, so we can find
# its leapsecs.dat.

.if !defined(PKG_SYSCONFDIR.libtai)
PKG_SYSCONFDIR.libtai!=							\
	${PKG_INFO} -Q PKG_SYSCONFDIR					\
		${DEPENDS_LIBTAI:C/:.*$//:Q} 2>/dev/null ||		\
	${ECHO} "PKG_SYSCONFDIR.libtai_not_set"
.  if empty(PKG_SYSCONFDIR.libtai:M*not_set)
MAKEVARS+=	PKG_SYSCONFDIR.libtai
.  endif
.endif

BUILD_DEFS+=		QMAILDIR QMAILPATCHES QMAIL_QUEUE_DIR QMAIL_QUEUE_EXTRA
BUILD_DEFS+=		QMAIL_ALIAS_USER QMAIL_DAEMON_USER QMAIL_LOG_USER
BUILD_DEFS+=		QMAIL_ROOT_USER QMAIL_PASSWD_USER QMAIL_QUEUE_USER
BUILD_DEFS+=		QMAIL_REMOTE_USER QMAIL_SEND_USER
BUILD_DEFS+=		QMAIL_QMAIL_GROUP QMAIL_NOFILES_GROUP

.if !empty(QMAIL_QUEUE_DIR:M${QMAILDIR}/*)
PKG_FAIL_REASON+=	"QMAIL_QUEUE_DIR must not be under ${QMAILDIR}"
.endif

.if !empty(QMAIL_QUEUE_EXTRA)
USE_TOOLS+=		expr
QUEUE_EXTRA=		"T${QMAIL_QUEUE_EXTRA}\\0"
QUEUE_EXTRALEN_cmd=	${EXPR} `${ECHO_N} ${QMAIL_QUEUE_EXTRA} | ${WC} -c` + 2
SUBST_CLASSES+=		logging
SUBST_STAGE.logging=	do-configure
SUBST_FILES.logging=	extra.h
SUBST_SED.logging=	-e 's|0|${QUEUE_EXTRALEN_cmd:sh}|g'
SUBST_SED.logging+=	-e 's|""|${QUEUE_EXTRA}|g'
SUBST_MESSAGE.logging=	Setting QUEUE_EXTRA.
.endif

SUBST_CLASSES+=		caseclash
SUBST_STAGE.caseclash=	do-configure
SUBST_FILES.caseclash=	hier.c
SUBST_SED.caseclash=	-e 's|"doc","INSTALL"|".","doc/INSTALL"|g'
SUBST_SED.caseclash+=	-e 's|"doc","SENDMAIL"|".","doc/SENDMAIL"|g'

SUBST_CLASSES+=		catpages
SUBST_STAGE.catpages=	do-configure
SUBST_FILES.catpages=	hier.c
SUBST_SED.catpages=	-e 's|.*"man/cat[0-9]".*||g'
SUBST_SED.catpages+=	-e 's|.*"tcp-environ\.5".*||g'	# also in ucspi-tcp

.if defined(MANZ)
SUBST_CLASSES+=		manzpages
SUBST_STAGE.manzpages=	post-build
SUBST_FILES.manzpages=	hier_destdir.c
SUBST_SED.manzpages=	-e 's|\(.*"man/man[0-9]",".*\.[0-9]\)|\1.gz|g'
.endif

SUBST_CLASSES+=		paths
SUBST_STAGE.paths=	do-configure
SUBST_FILES.paths=	README.*
SUBST_VARS.paths=	PKGNAME PKG_INFO PREFIX GREP

SUBST_CLASSES+=		libtai
SUBST_STAGE.libtai=	do-configure
SUBST_FILES.libtai=	leapsecs_read.c
SUBST_SED.libtai=	-e 's|@PKG_SYSCONFDIR@|${PKG_SYSCONFDIR.libtai}|g'

SUBST_FILES.djbware+=	cdb_seek.c dns.c

PKG_USERS_VARS+=	QMAIL_ALIAS_USER QMAIL_DAEMON_USER QMAIL_LOG_USER
PKG_USERS_VARS+=	QMAIL_ROOT_USER QMAIL_PASSWD_USER QMAIL_QUEUE_USER
PKG_USERS_VARS+=	QMAIL_REMOTE_USER QMAIL_SEND_USER
PKG_GROUPS_VARS+=	QMAIL_QMAIL_GROUP QMAIL_NOFILES_GROUP
PKG_GROUPS=		${QMAIL_QMAIL_GROUP} ${QMAIL_NOFILES_GROUP}
PKG_USERS+=		${QMAIL_ALIAS_USER}:${QMAIL_NOFILES_GROUP}
PKG_USERS+=		${QMAIL_DAEMON_USER}:${QMAIL_NOFILES_GROUP}
PKG_USERS+=		${QMAIL_LOG_USER}:${QMAIL_NOFILES_GROUP}
PKG_USERS+=		${QMAIL_PASSWD_USER}:${QMAIL_NOFILES_GROUP}
PKG_USERS+=		${QMAIL_QUEUE_USER}:${QMAIL_QMAIL_GROUP}
PKG_USERS+=		${QMAIL_REMOTE_USER}:${QMAIL_QMAIL_GROUP}
PKG_USERS+=		${QMAIL_SEND_USER}:${QMAIL_QMAIL_GROUP}
.for user in ${PKG_USERS:C/\:.*//}
PKG_HOME.${user}=	${QMAILDIR}
.endfor
PKG_HOME.alias=		${QMAILDIR}/alias

READMES=		README.pkgsrc

# Record all patches applied, starting with the non-optional ones:
QMAILPATCHES=			netqmail:${DEFAULT_DISTFILES}

QMAILPATCHES+=			tls:${TLSREMOTE_PATCH}
TLSREMOTE_PATCH=		netqmail-1.06-tls-20160918-onlyremote-20181107.patch
PATCHFILES+=			${TLSREMOTE_PATCH}
SITES.${TLSREMOTE_PATCH}=	https://schmonz.com/qmail/tlsonlyremote/

QMAILPATCHES+=			bigdns:${BIGDNS_PATCH}
BIGDNS_PATCH=			qmail-103.patch
PATCHFILES+=			${BIGDNS_PATCH}
SITES.${BIGDNS_PATCH}=		http://www.ckdhr.com/ckd/
SITES.${BIGDNS_PATCH}+=		${MASTER_SITE_LOCAL}
PATCH_DIST_STRIP.${BIGDNS_PATCH}=-p1

QMAILPATCHES+=			destdir:${DESTDIR_PATCH}
DESTDIR_PATCH=			netqmail-1.06-destdir-20181217.patch
PATCHFILES+=			${DESTDIR_PATCH}
SITES.${DESTDIR_PATCH}=		https://schmonz.com/qmail/destdir/

QMAILPATCHES+=			maildiruniq:${MAILDIRUNIQ_PATCH}
MAILDIRUNIQ_PATCH=		qmail-1.03-maildir-uniq.patch
PATCHFILES+=			${MAILDIRUNIQ_PATCH}
SITES.${MAILDIRUNIQ_PATCH}=	http://www.memoryhole.net/qmail/
PATCH_DIST_STRIP.${MAILDIRUNIQ_PATCH}=-p1
PATCH_DIST_CAT.${MAILDIRUNIQ_PATCH}= \
				${SED} -e 's|"057"|"\\\\057"|' \
				-e 's|"072"|"\\\\072"|' \
				< ${MAILDIRUNIQ_PATCH}

QMAILPATCHES+=			outgoingip:${OUTGOINGIP_PATCH}
OUTGOINGIP_PATCH=		outgoingip.patch
PATCHFILES+=			${OUTGOINGIP_PATCH}
SITES.${OUTGOINGIP_PATCH}=	http://www.qmail.org/

QMAILPATCHES+=			qbiffutmpx:${QBIFFUTMPX_PATCH}
QBIFFUTMPX_PATCH=		netqmail-1.06-qbiffutmpx-20170820.patch
PATCHFILES+=			${QBIFFUTMPX_PATCH}
SITES.${QBIFFUTMPX_PATCH}=	https://schmonz.com/qmail/qbiffutmpx/

QMAILPATCHES+=			remote:${REMOTE_PATCH}
REMOTE_PATCH=			netqmail-1.06-qmailremote-20170716.patch
PATCHFILES+=			${REMOTE_PATCH}
SITES.${REMOTE_PATCH}=		https://schmonz.com/qmail/remote/

QMAILPATCHES+=			spp:${SPP_PATCH}:${SPP_PATCHFILE_cmd:sh}
SPP_PATCH=			qmail-spp-0.42.tar.gz
PATCHFILES+=			${SPP_PATCH}
SITES.${SPP_PATCH}=		${MASTER_SITE_SOURCEFORGE:=qmail-spp/}
SPP_PATCHFILE=			./qmail-spp-0.42/netqmail-spp.diff
SPP_PATCHFILE_cmd=		${BASENAME} ${SPP_PATCHFILE}
PATCH_DIST_CAT.${SPP_PATCH}=	${TAR} -C ${WRKDIR} -zxf ${SPP_PATCH} ${SPP_PATCHFILE} \
				&& ${CAT} ${WRKDIR}/${SPP_PATCHFILE} \
				| ${SED} -e 's|sppfok \!= 1|sppfok == -1|'
PATCH_DIST_STRIP.${SPP_PATCH}=	-p1
LICENSE+=			AND gnu-gpl-v2

QMAILPATCHES+=			taileapsecs:${TAILEAPSECS_PATCH}
TAILEAPSECS_PATCH=		netqmail-1.05-TAI-leapsecs.patch
PATCHFILES+=			${TAILEAPSECS_PATCH}
SITES.${TAILEAPSECS_PATCH}=	https://su.bze.ro/software/
PATCH_DIST_STRIP.${TAILEAPSECS_PATCH}=-p1
PATCH_DIST_CAT.${TAILEAPSECS_PATCH}= \
				${SED} -e 's|"/etc/leapsecs.dat"|"@PKG_SYSCONFDIR@/leapsecs.dat"|' \
				< ${TAILEAPSECS_PATCH}

post-extract:
	for i in ${READMES}; do						\
		${CP} ${FILESDIR}/$$i ${WRKSRC} || ${TRUE};		\
	done
	mkdir ${WRKSRC}/doc &&						\
	for i in INSTALL SENDMAIL; do					\
		${MV} ${WRKSRC}/$$i ${WRKSRC}/doc/$$i;			\
	done

post-patch:
	cd ${WRKSRC}; \
	for i in ssl_timeoutio.c tls.c; do \
		( ${ECHO} '#ifdef TLS'; ${CAT} $$i; ${ECHO} '#endif' ) > $$i.new; \
		mv $$i.new $$i; \
	done

post-build:
	cd ${WRKSRC}; \
	${SED} -e 's|${QMAILDIR}/control/|${PKG_SYSCONFDIR}/.pkgsrc-defaults-do-not-edit/|' < config-fast > config-fast-pkgsrc

pre-install:
	${MKDIR} ${DESTDIR}${QMAILDIR}
	${MKDIR} ${DESTDIR}${QMAIL_QUEUE_DIR}
	# keep in sync with INSTALL:PRE-INSTALL
	${LN} -s ${DESTDIR}${EGDIR}/alias	${DESTDIR}${QMAILDIR}/alias
	${LN} -s ${DESTDIR}${PREFIX}/bin	${DESTDIR}${QMAILDIR}/bin
	${LN} -s ${DESTDIR}${EGDIR}/boot	${DESTDIR}${QMAILDIR}/boot
	${LN} -s ${DESTDIR}${EGDIR}/control	${DESTDIR}${QMAILDIR}/control
	${LN} -s ${DESTDIR}${DOCDIR}		${DESTDIR}${QMAILDIR}/doc
	${LN} -s ${DESTDIR}${PREFIX}/${PKGMANDIR} ${DESTDIR}${QMAILDIR}/man
	${LN} -s ${DESTDIR}${QMAIL_QUEUE_DIR}	${DESTDIR}${QMAILDIR}/queue
	${LN} -s ${DESTDIR}${EGDIR}/users	${DESTDIR}${QMAILDIR}/users

post-install:
	for i in ${READMES}; do						\
		${INSTALL_DATA} ${WRKSRC}/$$i ${DESTDIR}${DOCDIR};	\
	done

	cd ${WRKSRC} && ${MAKE} instcheck install-destdir

	${INSTALL_PROGRAM_DIR} ${DESTDIR}${SHAREDIR}/setup
	for i in ${SETUP_PROGRAMS}; do					\
		${INSTALL_PROGRAM} ${WRKSRC}/$$i			\
			${DESTDIR}${SHAREDIR}/setup;			\
	done
	for i in ${SETUP_SCRIPTS}; do					\
		${INSTALL_SCRIPT} ${WRKSRC}/$$i				\
			${DESTDIR}${SHAREDIR}/setup;			\
	done

.include "../../mk/djbware.mk"
.include "../../mk/bsd.pkg.mk"