summaryrefslogtreecommitdiff
blob: 58bc90639ae8d0a7d1cce98534bb0b4345a3c153 (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
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit toolchain-funcs flag-o-matic

HOMEPAGE="https://www.sdaoden.eu/code.html"
DESCRIPTION="Enhanced mailx-compatible mail client based on Heirloom mailx (nail)"
LICENSE="BSD BSD-4 ISC RSA"

SRC_URI="https://ftp.sdaoden.eu/${P}.tar.xz"
SLOT="0"
KEYWORDS="~amd64 ~loong ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
IUSE="idn kerberos net +split-usr ssl"

RDEPEND="
	sys-libs/ncurses:0=
	virtual/libiconv
	idn? ( net-dns/libidn2 )
	net? (
		ssl? ( dev-libs/openssl:0= )
		kerberos? ( virtual/krb5 )
	)
	!mail-client/mailx
	!net-mail/mailutils
	!mail-client/nail
"
DEPEND="${RDEPEND}"
BDEPEND="
	app-arch/xz-utils[extra-filters(-)]
	app-alternatives/awk
"

src_configure() {
	has_cflag() {
		local x var="CFLAGS[*]"
		for x in ${!var} ; do
			[[ ${x} == $1 ]] && return 0
		done
		return 1
	}

	# Fails to build without replace Bug 860357
	replace-flags -O[0gs] -O1
	# A valid -O option is necessary Bug 888613
	has_cflag -O* || append-cflags -O1
	append-cflags -std=c99
	local confopts=(
		CC="$(tc-getCC)"
		strip=/bin/true
		OPT_AUTOCC=no
		VAL_PREFIX="${EPREFIX}"/usr
		VAL_SYSCONFDIR="${EPREFIX}"/etc
		VAL_MTA="${EPREFIX}/usr/sbin/sendmail"
		VAL_MAIL='/var/spool/mail'
		VAL_PAGER=less
		$(usex idn VAL_IDNA=idn2 OPT_IDNA=no)
		VERBOSE=1
	)

	if use net; then
		confopts+=( OPT_TLS=$(usex ssl require no)
			OPT_GSSAPI=$(usex kerberos require no)
		)
	else
		confopts+=( OPT_NET=no )
	fi

	tc-is-cross-compiler && confopts+=( OPT_CROSS_BUILD=yes )

	# Cannot use emake or bad options saved Bug 879065
	make "${confopts[@]}" config || die
}

src_compile() {
	emake build
}

src_install() {
	# Use /usr/sbin/sendmail by default and provide an example
	cat <<- EOSMTP >> nail.rc

		# Use the local sendmail (/usr/sbin/sendmail) binary by default.
		# (Uncomment the following line to use a SMTP server)
		#set smtp=localhost

		# Ask for CC: list too.
		set askcc
	EOSMTP

	emake DESTDIR="${D}" install

	dodoc INSTALL NEWS README THANKS

	if use split-usr ; then
		dodir /bin
		dosym ../usr/bin/mailx /bin/mail
	fi
	dosym s-nail /usr/bin/mailx
	dosym mailx /usr/bin/mail
	dosym mailx /usr/bin/Mail

	dosym s-nail.1 /usr/share/man/man1/mailx.1
	dosym mailx.1 /usr/share/man/man1/mail.1
	dosym mailx.1 /usr/share/man/man1/Mail.1
}