# Contributor: Steffen Nurpmeso <steffen@sdaoden.eu>
# Contributor: Ivan Tham <pickfire@riseup.net>
# Maintainer: Steffen Nurpmeso <steffen@sdaoden.eu>
pkgname=s-nail
pkgver=14.9.9
pkgrel=1
pkgdesc="SysV mail/BSD Mail/POSIX mailx: send and receive Internet mail"
url="https://www.sdaoden.eu/code.html#s-mailx"
arch="all"
license="BSD"
makedepends="libressl-dev libidn-dev ncurses-dev krb5-dev"
options="suid"
replaces="mailx"
subpackages="$pkgname-doc"
source="https://ftp.sdaoden.eu/s-nail-$pkgver.tar.xz
	fix-inv-mem-access.patch"
builddir="$srcdir/"$pkgname-$pkgver

# LD_LIBRARY_PATH is included via -rpath, so use system defaults only.
# And ensure no other paths sneak in.
unset LIBRARY_PATH LD_RUN_PATH
PATH=/sbin:/usr/sbin:/bin:/usr/bin
C_INCLUDE_PATH=/usr/include
LD_LIBRARY_PATH=/lib:/usr/lib
export PATH C_INCLUDE_PATH LD_LIBRARY_PATH

build() {
	cd "$builddir"
	make \
		VAL_SID= VAL_MAILX=mail \
		VAL_PREFIX=/usr \
		VAL_SYSCONFDIR=/etc \
		\
		OPT_AUTOCC=no \
		\
		config &&
	make build # XXX unite with config in v14.9.10
}

check() {
	cd "$builddir"
	make test
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

sha512sums="f0004952f7189a2549e01489b600a10a36f1fa3ba0b6c6a871c4ee99d3d3d49e97ed5a8068fa1692b7fd91d2b243d05dbc5d61fe3f1dc2e9ba9187d9d31707c4  s-nail-14.9.9.tar.xz
47639f0f013724040aa70a47180b5e286f4143d2ecef960c27eef43bcf5d8f60db8c7c1aedb4d158779b783f79409cbd7c5b703ed28666e8cf80eb4448f86125  fix-inv-mem-access.patch"

