# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=open-isns
pkgver=0.97
pkgrel=2
pkgdesc="iSNS server and client for Linux"
url="https://github.com/open-iscsi/open-isns"
arch="all"
license="LGPL-2.0"
makedepends="autoconf automake libressl-dev musl-dev"
options="!check"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lib"
source="$pkgname-$pkgver.tar.gz::https://github.com/open-iscsi/open-isns/archive/v$pkgver.tar.gz
	libressl.patch
	musl-fixes.patch
	"
builddir="$srcdir"/$pkgname-$pkgver

prepare() {
	cd "$builddir"
	default_prepare
	update_config_sub
	autoconf && autoheader
}

build() {
	cd "$builddir"
	./configure \
		--host=$CHOST \
		--build=$CBUILD \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--enable-shared
	make all
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
	make DESTDIR="$pkgdir" install_hdrs
	make DESTDIR="$pkgdir" install_lib
	rm -rf "$pkgdir"/usr/lib/systemd
}

lib() {
	cd "$builddir"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr
}

sha512sums="78c934162d5a1d093bccd49449d4ef369b896d34309d76b4963d643a699640617c4fe064388c481c35b9be26e012f19713f3aad378af9ad88fa94c3d300e919d  open-isns-0.97.tar.gz
3a01a78c19114801ce4d80568eca158615f338a27133eb7639258ebb9114afa66cbbf0c0d871f00b7e85a4903f1c2444866daaccc3e3b187d0d4d47d7e86adc2  libressl.patch
14eb43b8659c4c917fb35f2e33bffb90c7288555c3feb1ba4afd502c3e509bb44d0ad91b6c4ef09c68cd30eb812df11440a1c28720ee9be8cf4af6c0d8d6dc8d  musl-fixes.patch"
