aboutsummaryrefslogtreecommitdiffstats
path: root/mail/smx/Makefile
blob: 9d27bfa3ca8074e5e7169053ba52c261a26d4d43 (plain) (blame)
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
# New ports collection makefile for:    sms
# Date created:             04 Nov 2005
# Whom:                 dirk.meyer@dinoex.sub.org
#
# $FreeBSD$
#

PORTNAME=   smx
PORTVERSION=    0.0.0.0
CATEGORIES= mail ipv6
MASTER_SITES=   ftp://ftp.sendmail.org/pub/sendmail/ \
        ${MASTER_SITE_RINGSERVER:S,%SUBDIR%,net/mail/sendmail/&,}
PKGNAMESUFFIX?= ${TLS_SUFFIX}${SASL_SUFFIX}${LDAP_SUFFIX}${BERKELEYDB_SUFFIX}${PMILTER_SUFFIX}${PKGNAMESUFFIX2}
DISTNAME=   ${PORTNAME2}-${PORTVERSION}

MAINTAINER= dinoex@FreeBSD.org
COMMENT=    Secure and efficient mail gateway

PORTNAME2=  smX
WRKSRC=     ${WRKDIR}/${PORTNAME2}-${PORTVERSION}
USE_REINPLACE=  yes
GNU_CONFIGURE=  yes
CONFIGURE_TARGET=
CONFIGURE_ARGS+=    --disable-dependency-tracking
MAKE_ENV+=  SMXCONFDIR="${SMXCONFDIR}"
MAN5=       sendmailx.conf.5
MAN8=       createmap.8 mailq.8 mcp.8 milter-spamd.8 qmgr.8 \
        qmgrctl.8 runas.8 sendmailx.8 smar.8 smtpc.8 smtps.8
MLINKS=     sendmailx.conf.5 smx.conf.5 \
        sendmailx.8 sendmailX.8
PORTDOCS=   README.dvi README.html README.pdf README.ps README.txt \
        img1.png img2.png img3.png img4.png img5.png img6.png \
        nx_grp_g.png overview1.eps overview1.gif overview1.pdf \
        prev_g.png up_g.png pmilter.api.tex
PLIST_SUB+= SPOOL=${DESTDIR}/var/spool
PLIST_SUB+= NOLOGIN=${NOLOGIN_CMD}
EXTRA_SBIN= libcheck/noroot libconf/tree libmta/statit \
        libmta/t-hostname checks/t-getgroup

# Options to define Features:
# SMX_WITHOUT_TLS=yes
# SMX_WITHOUT_SASL=yes
# SMX_WITH_PMILTER=yes
# SMX_WITH_INTERNAL_BERKELEYD=yes
# SMX_WITH_BERKELEYDB_VER=41
# SMX_WITH_BERKELEYDB_VER=42
# SMX_WITH_BERKELEYDB_VER=43

# default config:
SMXCONFDIR?=    ${PREFIX}/etc/smx

.if defined(SMX_WITH_INTERNAL_BERKELEYD)
BERKELEYDB_SUFFIX=  -intbdb
PLIST_SUB+= WITH_BDBINT=""
.else
.if !defined(SMX_WITH_BERKELEYDB_VER)
SMX_WITH_BERKELEYDB_VER=43
.endif
.if ${SMX_WITH_BERKELEYDB_VER} == "41"
BERKELEYDB_PORT?=   databases/db41
BERKELEYDB_LIB?=        db41
BERKELEYDB_LIBDIR?= ${LOCALBASE}/lib
BERKELEYDB_INCLUDE?=    ${LOCALBASE}/include/db41
.elif ${SMX_WITH_BERKELEYDB_VER} == "42"
BERKELEYDB_PORT?=   databases/db42
BERKELEYDB_LIB?=        db-4.2
BERKELEYDB_LIBDIR?= ${LOCALBASE}/lib/db42
BERKELEYDB_INCLUDE?=    ${LOCALBASE}/include/db42
.elif ${SMX_WITH_BERKELEYDB_VER} == "43"
BERKELEYDB_PORT?=   databases/db43
BERKELEYDB_LIB?=        db-4.3
BERKELEYDB_LIBDIR?= ${LOCALBASE}/lib/db43
BERKELEYDB_INCLUDE?=    ${LOCALBASE}/include/db43
.endif
LIB_DEPENDS+=       ${BERKELEYDB_LIB}:${PORTSDIR}/${BERKELEYDB_PORT}
CONFIGURE_ARGS+=    --disable-included-bdb
CONFIGURE_ARGS+=    --with-bdb-incdir=${BERKELEYDB_INCLUDE}
CONFIGURE_ARGS+=    --with-bdb-libdir=${BERKELEYDB_LIBDIR}
PLIST_SUB+= WITH_BDBINT="@comment "
.endif

.if defined(SMX_WITHOUT_SASL)
SASL_SUFFIX?=   -nosasl
CONFIGURE_ARGS+=    --disable-SASL
.else
LIB_DEPENDS+=   sasl2.2:${PORTSDIR}/security/cyrus-sasl2
.if !defined(SMX_WITHOUT_SASLAUTHD)
RUN_DEPENDS+=   ${LOCALBASE}/sbin/saslauthd:${PORTSDIR}/security/cyrus-sasl2-saslauthd
.endif
CONFIGURE_ARGS+=    --enable-SASL
CONFIGURE_ARGS+=    --with-sasl-incdir=${LOCALBASE}/include
CONFIGURE_ARGS+=    --with-sasl-libdir=${LOCALBASE}/lib
.endif

.if defined(SMX_WITHOUT_TLS) || defined(WITHOUT_TLS)
TLS_SUFFIX?=    -notls
CONFIGURE_ARGS+=    --disable-TLS
.else
CONFIGURE_ARGS+=    --enable-TLS
.endif

.if defined(SMX_WITH_PMILTER) || defined(WITH_PMILTER)
PMILTER_SUFFIX?=    -pmilter
CONFIGURE_ARGS+=    --enable-pmilter
USE_OPENSSL=    yes
.else
CONFIGURE_ARGS+=    --disable-pmilter
.endif

.if defined(BATCH)
EXTRA_PATCHES+=     ${FILESDIR}/batch.patch
.endif

post-configure:
    @${CP} ${WRKSRC}/misc/sm.check.sh ${WRKSRC}/misc/sm.setup.sh \
        ${WRKDIR}/
     @${REINPLACE_CMD} -e 's|/etc/smx|${SMXCONFDIR}|g' \
        -e 's|$${SD}/misc|${PREFIX}/bin|' \
        -e 's|$${SD}/libcheck|${PREFIX}/sbin|' \
        -e 's|$${SD}/libmta|${PREFIX}/sbin|' \
        -e 's|$${SD}/checks|${PREFIX}/sbin|' \
        ${WRKDIR}/sm.check.sh
     @${REINPLACE_CMD} -e 's|/etc/smx|${SMXCONFDIR}|g' \
        -e 's|[.]/misc|${PREFIX}/bin|' \
        -e 's|$${S}/libconf|${PREFIX}/sbin|' \
        -e 's|[.]/libmta|${PREFIX}/sbin|' \
        -e 's|[.]/checks|${PREFIX}/sbin|' \
        -e 's|=mcp.sh|=${PREFIX}/etc/rc.d/smx-mcp.sh|' \
        ${WRKDIR}/sm.setup.sh

test:
    (cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
    ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} check)

pre-install:
    if ! pw groupshow smxm; then pw groupadd smxs -g 260; fi
    if ! pw groupshow smxq; then pw groupadd smxq -g 261; fi
    if ! pw groupshow smxc; then pw groupadd smxc -g 262; fi
    if ! pw groupshow smxm; then pw groupadd smxm -g 263; fi
    if ! pw groupshow smx; then pw groupadd smx -g 264; fi
    if ! pw usershow smxs; then pw useradd smxs -g smxs -u 260 \
        -h - -d ${NONEXISTENT} -s ${NOLOGIN_CMD} -c "Sendmail X SMTPS"; fi
    if ! pw usershow smxq; then pw useradd smxq -g smxq -u 261 \
        -h - -d ${NONEXISTENT} -s ${NOLOGIN_CMD} -c "Sendmail X QMGR"; fi
    if ! pw usershow smxc; then pw useradd smxc -g smxc -u 262 \
        -h - -d ${NONEXISTENT} -s ${NOLOGIN_CMD} -c "Sendmail X SMTPC"; fi
    if ! pw usershow smxm; then pw useradd smxm -g smxm -u 263 \
        -h - -d ${NONEXISTENT} -s ${NOLOGIN_CMD} -c "Sendmail X misc"; fi
    if ! pw usershow smx; then pw useradd smx -g smx -u 264 \
        -h - -d ${NONEXISTENT} -s ${NOLOGIN_CMD} -c "Sendmail X other"; fi
    pw groupmod smxc -m smxs
    pw groupmod smxm -m smxs,smxq
.if !defined(BATCH)
    ${SHELL} ${WRKSRC}/misc/sm.setup.sh
.endif

post-install:
    ${INSTALL_SCRIPT} ${WRKDIR}/sm.check.sh ${PREFIX}/sbin/
    ${INSTALL_SCRIPT} ${WRKDIR}/sm.setup.sh ${PREFIX}/sbin/
.for i in ${EXTRA_SBIN}
    ${INSTALL_PROGRAM} ${WRKSRC}/${i} ${PREFIX}/sbin/
.endfor
.if !defined(NOPORTDOCS)
    ${MKDIR} ${DOCSDIR}
    @cd ${WRKSRC}/doc && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR}/
.endif

.include <bsd.port.pre.mk>

.if !defined(UID)
UID!=   ${ID} -u
.endif
.if ${UID} != 0
post-build: test
.endif

.if ${OSVERSION} < 500000
NOLOGIN_CMD?=   /sbin/nologin
.else
NOLOGIN_CMD?=   /usr/sbin/nologin
.endif

.include <bsd.port.post.mk>