1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 inherit eutils multilib systemd toolchain-funcs user
7 DESCRIPTION="Widely-used Mail Transport Agent (MTA)"
8 HOMEPAGE="http://www.sendmail.org/"
9 SRC_URI="ftp://ftp.sendmail.org/pub/${PN}/${PN}.${PV}.tar.gz"
11 LICENSE="Sendmail GPL-2" # GPL-2 is here for initscript
13 KEYWORDS="~alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86"
14 IUSE="ssl ldap sasl tcpd mbox ipv6 nis sockets"
16 DEPEND="net-mail/mailbase
18 sasl? ( >=dev-libs/cyrus-sasl-2.1.10 )
19 tcpd? ( sys-apps/tcp-wrappers )
20 ssl? ( dev-libs/openssl:0= )
21 ldap? ( net-nds/openldap )
26 >=net-mail/mailbase-0.00
37 !<mail-mta/ssmtp-2.64-r2
38 !>=mail-mta/ssmtp-2.64-r2[mta]"
40 PDEPEND="!mbox? ( mail-filter/procmail )"
42 # libmilter library is part of sendmail, but it does not share the version number with it.
43 # In order to find the right libmilter version number, check SMFI_VERSION definition
44 # that can be found in ${S}/include/libmilter/mfapi.h (see also SM_LM_VRS_* defines).
45 # For example, version 1.0.1 has a SMFI_VERSION of 0x01000001.
50 enewuser smmsp 209 -1 /var/spool/mqueue smmsp
54 epatch "${FILESDIR}"/"${PN}"-8.14.6-build-system.patch
55 epatch "${FILESDIR}"/sendmail-delivered_hdr.patch
56 epatch "${FILESDIR}"/libmilter-sharedlib.patch
57 epatch "${FILESDIR}"/"${PN}"-8.14.5+db-5.0.patch
58 epatch "${FILESDIR}"/sendmail-starttls-multi-crl.patch
60 local confCC="$(tc-getCC)"
61 local confCCOPTS="${CFLAGS}"
62 local confLDOPTS="${LDFLAGS}"
63 local confMAPDEF="-DMAP_REGEX"
64 local conf_sendmail_LIBS=""
65 use sasl && confLIBS="${confLIBS} -lsasl2" \
66 && confENVDEF="${confENVDEF} -DSASL=2" \
67 && confCCOPTS="${confCCOPTS} -I/usr/include/sasl" \
68 && conf_sendmail_LIBS="${conf_sendmail_LIBS} -lsasl2"
69 use tcpd && confENVDEF="${confENVDEF} -DTCPWRAPPERS" \
70 && confLIBS="${confLIBS} -lwrap"
71 use ssl && confENVDEF="${confENVDEF} -DSTARTTLS -D_FFR_DEAL_WITH_ERROR_SSL" \
72 && confENVDEF="${confENVDEF} -D_FFR_TLS_1" \
73 && confLIBS="${confLIBS} -lssl -lcrypto" \
74 && conf_sendmail_LIBS="${conf_sendmail_LIBS} -lssl -lcrypto"
75 use ldap && confMAPDEF="${confMAPDEF} -DLDAPMAP" \
76 && confLIBS="${confLIBS} -lldap -llber"
77 use ipv6 && confENVDEF="${confENVDEF} -DNETINET6"
78 use nis && confENVDEF="${confENVDEF} -DNIS"
79 use sockets && confENVDEF="${confENVDEF} -DSOCKETMAP"
80 sed -e "s:@@confCCOPTS@@:${confCCOPTS}:" \
81 -e "s/@@confLDOPTS@@/${confLDOPTS}/" \
82 -e "s/@@confCC@@/${confCC}/" \
83 -e "s/@@confMAPDEF@@/${confMAPDEF}/" \
84 -e "s/@@confENVDEF@@/${confENVDEF}/" \
85 -e "s/@@confLIBS@@/${confLIBS}/" \
86 -e "s/@@conf_sendmail_LIBS@@/${conf_sendmail_LIBS}/" \
87 "${FILESDIR}"/site.config.m4 > devtools/Site/site.config.m4
91 sh Build AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" || die "compilation failed in main Build script"
93 sh Build AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" MILTER_SOVER=${LIBMILTER_VER} || die "libmilter compilation failed"
98 local MY_LIBDIR=/usr/$(get_libdir)
99 local MY_OBJDIR="obj.`uname -s`.`uname -r`.`uname -m`"
100 dodir /usr/bin ${MY_LIBDIR} /usr/include/libmilter
101 dodir /usr/share/man/man{1,5,8} /usr/sbin /var/log /usr/share/sendmail-cf
102 dodir /var/spool/{mqueue,clientmqueue} /etc/conf.d
103 keepdir /var/spool/{clientmqueue,mqueue}
104 for dir in libsmutil sendmail mailstats praliases smrsh makemap vacation editmap
106 make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
107 SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
108 MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
109 LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
110 MSPQOWN=root CFOWN=root CFGRP=root \
111 install -C "${MY_OBJDIR}/${dir}" \
112 || die "install failed"
114 for dir in rmail mail.local
116 make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
117 SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
118 MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
119 LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
120 MSPQOWN=root CFOWN=root CFGRP=root \
121 force-install -C "${MY_OBJDIR}/${dir}" \
122 || die "install failed"
125 make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
126 SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
127 MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
128 LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
129 MSPQOWN=root CFOWN=root CFGRP=root \
130 MILTER_SOVER=${LIBMILTER_VER} \
131 install -C "${MY_OBJDIR}/libmilter" \
132 || die "install failed"
134 fowners root:smmsp /usr/sbin/sendmail
135 fperms 2555 /usr/sbin/sendmail
136 fowners smmsp:smmsp /var/spool/clientmqueue
137 fperms 770 /var/spool/clientmqueue
138 fperms 700 /var/spool/mqueue
139 dosym /usr/sbin/makemap /usr/bin/makemap
140 dodoc FAQ KNOWNBUGS README RELEASE_NOTES doc/op/op.ps
141 newdoc sendmail/README README.sendmail
142 newdoc sendmail/SECURITY SECURITY
143 newdoc sendmail/TUNING TUNING
144 newdoc smrsh/README README.smrsh
145 newdoc libmilter/README README.libmilter
147 newdoc cf/README README.cf
148 newdoc cf/cf/README README.install-cf
149 cp -pPR cf/* "${D}"/usr/share/sendmail-cf
157 newins "${FILESDIR}"/sendmail.mc-r1 sendmail.mc
159 newins "${FILESDIR}"/sendmail-procmail.mc sendmail.mc
161 m4 "${D}"/usr/share/sendmail-cf/m4/cf.m4 "${D}"/etc/mail/sendmail.mc \
162 > "${D}"/etc/mail/sendmail.cf
163 echo "include(\`/usr/share/sendmail-cf/m4/cf.m4')dnl" \
164 > "${D}"/etc/mail/submit.mc
165 cat "${D}"/usr/share/sendmail-cf/cf/submit.mc >> "${D}"/etc/mail/submit.mc
166 echo "# local-host-names - include all aliases for your machine here" \
167 > "${D}"/etc/mail/local-host-names
168 cat <<- EOF > "${D}"/etc/mail/trusted-users
169 # trusted-users - users that can send mail as others without a warning
170 # apache, mailman, majordomo, uucp are good candidates
172 cat <<- EOF > "${D}"/etc/mail/access
173 # Check the /usr/share/doc/sendmail/README.cf file for a description
174 # of the format of this file. (search for access_db in that file)
175 # The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
180 cat <<- EOF > "${D}"/etc/conf.d/sendmail
181 # Config file for /etc/init.d/sendmail
182 # add start-up options here
183 SENDMAIL_OPTS="-bd -q30m -L sm-mta" # default daemon mode
184 CLIENTMQUEUE_OPTS="-Ac -q30m -L sm-cm" # clientmqueue
185 KILL_OPTS="" # add -9/-15/your favorite evil SIG level here
190 cat <<- EOF > "${D}"/etc/sasl2/Sendmail.conf
191 pwcheck_method: saslauthd
192 mech_list: PLAIN LOGIN
197 doinitd "${FILESDIR}"/sendmail
198 systemd_dounit "${FILESDIR}"/sendmail.service
199 systemd_dounit "${FILESDIR}"/sm-client.service
201 keepdir /usr/adm/sm.bin