# Contributor: ScrumpyJack <scrumpyjack@st.ilet.to>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=libasr
pkgver=1.0.2
pkgrel=5
pkgdesc="libasr is a free, simple and portable asynchronous resolver library"
url="https://www.opensmtpd.org"
arch="all"
license="ISC"
options="!check"
makedepends="mdocml bison libressl-dev automake autoconf libtool"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/OpenSMTPD/libasr/archive/libasr-$pkgver.tar.gz
	0001-Fix-NETDB_SUCCESS-value.patch
	0002-Replace-missing-res_randomid-with-the-more-secure-ar.patch
	0003-no-need-for-openssl-in-libasr.patch
	"
builddir=${srcdir}/${pkgname}-${pkgname}-${pkgver}

prepare() {
	default_prepare || return 1

	cd "$builddir"
	./bootstrap || return 1
}

build() {
	cd "$builddir"

	./configure --build=$CBUILD \
		--host=$CHOST \
		--with-pie \
		--with-Werror \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--with-mantype=man
	make
}

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

sha512sums="d70d5fb5728678074f4fd3d0f925b13a8a5ac9fec7a38277f2ed0e6b3f3fe2591845d035f43ece1ee16f1fdfd7d7443140ca36f171f94f310ed821b88b82b924  libasr-1.0.2.tar.gz
aebd80ae1fd33604f547833d4244161cc8551404c61e666967062e484a30d88f597e71c9f9956a3604bf02e625d8aabd9b4669d3efad1a2a15efb2f8acd8ac03  0001-Fix-NETDB_SUCCESS-value.patch
2bef347875b1ad4ec47a6d642e0f555f40906e19bce7684fd89c1c3c867f67fff8cf42ddd836480ee73a8b4491ef9385f84c12f39197d677d239f8ac23d740a0  0002-Replace-missing-res_randomid-with-the-more-secure-ar.patch
32ffc6e64d9eeb7aa37a2f4b4633ac462508f2ee7a9152b6c6b87aeebdcc89e809e839d4cc66ed49486b98d34706ff8cd86d8466663bd8712dacd99cfec64e03  0003-no-need-for-openssl-in-libasr.patch"