#Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libspf2
pkgver=1.2.10
pkgrel=2
pkgdesc="Sender Policy Framework library, a part of the SPF/SRS protocol pair."
url="http://www.libspf2.org"
arch="all"
license="LGPL-2.1 BSD-2"
subpackages="$pkgname-dev $pkgname-tools"
makedepends="autoconf automake libtool"
depends=
source="http://www.libspf2.org/spf/$pkgname-$pkgver.tar.gz
	0001-provide-dn_skipname.patch
	libspf2-libreplace-fix.patch
	netdb_success.patch
	musl-res_close.patch
	fix-gcc-variadic-macros.patch
	"

_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
	cd "$_builddir"
	update_config_sub || return 1
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	libtoolize --force && aclocal && automake --add-missing && autoconf \
		&& autoheader
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
}

tools() {
	pkgdesc="SPF daemon and command-line utility"
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/sbin
	mv "$pkgdir"/usr/bin/spfquery "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/spfd "$subpkgdir"/usr/sbin
	rm -fr "$pkgdir"/usr/bin
}

md5sums="7bb9937d0705649eaa8646de66dc3562  libspf2-1.2.10.tar.gz
24b77cb74901d56de89b24ef10b46b85  0001-provide-dn_skipname.patch
6dd2d5f33c5f1a5b7c14eec4c71767cd  libspf2-libreplace-fix.patch
e364ae123e18ec330339824e71774b44  netdb_success.patch
984f356b97d936395ee061d6c6003d0a  musl-res_close.patch
6b3c05768fe5adb2cc65fb8d5c0a42c2  fix-gcc-variadic-macros.patch"
sha256sums="d91e3de81ae287a2976c44f60283bd3000d720e6a112dc7142eedf1831b821c9  libspf2-1.2.10.tar.gz
b6038c035c08e31a5407ed06d4af490aea357c1e51c218a02c703a9eace9a072  0001-provide-dn_skipname.patch
f9ee6d10be25a52d2432ac62114c37e2dd4c00c8e11d908f2f2ed0d4ba71b139  libspf2-libreplace-fix.patch
381d3cb2ef4257eb93dc52b39944948705feaf29223fa263af9c362963eb136e  netdb_success.patch
8d7392aaf3db6f32c96c3f3dac6d928762e0149d966e98fbedc434308894e03b  musl-res_close.patch
96ce1bb636942923ef17505dd42b9de8b8cd4d817f84a315c8053c263725c5ec  fix-gcc-variadic-macros.patch"
sha512sums="162ce382628c6fcadac3e11f5a12442db622bb23f7ec503e16f5ba7fc88afdd777bce6b093c12a58210355985fd11b74b140f08fab347334d82d953dd183b130  libspf2-1.2.10.tar.gz
cc8c77963a3bc0c54442c81146cc27e482c43787586ab8885e3fe0fd2cfcba089f5a5cfeda4c3307fe5cc36ac8768f748d9a8467e9b8ca41e9ad157b61bbce49  0001-provide-dn_skipname.patch
226e1d7a1d381f35206aaecafb33955a6ecd08c8c18f4d6fe443e359f0139aeeb314012296a53e7c017d68373f4e1fa27010514296f15ab86f059e531866b95a  libspf2-libreplace-fix.patch
033dd1e959004f7a1026fb1de73813e934560101e04897297e468918ee28e4d7d0f271d6f05d984db22dd43e097f6aa133df18d11419b085d89db89b120750c9  netdb_success.patch
4fb8a28a667d8fe54a48fa89230446b758c6d532866ee26e8b9ef3032f6e0993ec19a2cc2fb265d18d259e35de6fe66183763bbc69c424de70ad8fe0dbcf7a2f  musl-res_close.patch
2face288cfb2cbcfced0f6d47f905b9efdccf696de780892c4e36b134bb4dbe77416b42f42f8ccb16da47551d800fe037899324dec33e140fb8cea0f201abd74  fix-gcc-variadic-macros.patch"
