# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=unfs3
pkgver=0.9.22
pkgrel=4
pkgdesc="A user-space implementation of the NFSv3 server specification"
url="http://unfs3.sourceforge.net/"
arch="all"
license='GPL'
depends="rpcbind"
makedepends="flex-dev libtirpc-dev"
subpackages="$pkgname-doc"
source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
	unfs3-0.9.22-musl.patch
	unfs3.confd
	unfs3.initd
	"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	export CFLAGS="$CFLAGS $(pkgconf --cflags libtirpc)"
	export LDFLAGS="$LDFLAGS $(pkgconf --libs-only-L libtirpc)"
	export LIBS="$LIBS $(pkgconf --libs-only-l libtirpc)"

	sed -i '/LDFLAGS=/ s,-R/usr/ucblib,,' ./configure

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man
	make -j1
}

check() {
	cd "$builddir"
	./unfsd -h
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir/" install
	install -D -m0644 "$srcdir"/unfs3.confd "$pkgdir"/etc/conf.d/unfs3
	install -D -m0755 "$srcdir"/unfs3.initd "$pkgdir"/etc/init.d/unfs3
}

sha512sums="b1e4b7f5b7b7de27bb5411c69363a6b40be0fcf1f772e283f0868a2155fa9ea4b9b8e7f05b1706e41cf09dd2ee4baab472a01bc4640ae47e3be2a19d8d3f5f9e  unfs3-0.9.22.tar.gz
f2221651fad842acb8b5fd637514caa07300f627efd5b168ee2939ab3b6ea55fdefa3c3f3336425e255ee7badd326528c722d4064a04936b5468aabc79cbca02  unfs3-0.9.22-musl.patch
e3a3b7a71117482fd3214eadfd957f5cd3f05da268f748f931945c390f1d8e46e19b33d53b2ce0505c61745f8dd6285f7a9de409196fedef07d23ae029f1c035  unfs3.confd
105b1ac6d0a65b3ba19bb8ada17d1ae865cf14e71e6a3838df1e6d34d2738457f0019258fd10a4594783074c10be44db75417677290bdd6862ba73b4c370b07e  unfs3.initd"
