# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=msmtp
pkgver=1.8.26
pkgrel=0
pkgdesc="SMTP client with a sendmail compatible interface"
url="https://marlam.de/msmtp/"
arch="all"
license="GPL-3.0-or-later"
options="!check" # no test suite
makedepends="gettext-dev openssl-dev libgsasl-dev libidn2-dev"
subpackages="$pkgname-doc $pkgname-lang $pkgname-openrc $pkgname-vim:vim:noarch"
source="https://marlam.de/msmtp/releases/msmtp-$pkgver.tar.xz
	msmtp.confd
	msmtp.initd
	"

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-tls=openssl \
		--with-libgsasl
	make
}

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

	install -Dm755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
	install -Dm644 "$srcdir/$pkgname.confd" "$pkgdir/etc/conf.d/$pkgname"

	install -Dm644 README NEWS -t "$pkgdir"/usr/share/doc/$pkgname/
	install -Dm644 scripts/vim/$pkgname.vim \
		"$pkgdir"/usr/share/vim/vimfiles/syntax/$pkgname.vim
}

vim() {
	depends=""
	pkgdesc="Vim syntax for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel vim"

	amove usr/share/vim
}

sha512sums="
36fa4a571079b0e1141e645f2a565f3c7699e1899f6ece66e3539bed595473488bdf147ed6ff1bff103c6240e484b2c357122292d5eae65ac4c0f74215eb556c  msmtp-1.8.26.tar.xz
3839d7e8400cf897830c674f59563e225096d9755121d1ac14f3b493ab4cc0672228a9b14b9d9620d566593e2ae27d322a78c46791c6b5166ab82275d25dc0d3  msmtp.confd
0e1b32b07ccac6f5a174a1e317390815b459a4a7ca4f15672456ac0a30c89edb93001a8047c38d1f8da65b9f07a7b17b3270a0a07248a6be248500cd42773cef  msmtp.initd
"
