# Template file for 'nspr'
pkgname=nspr
version=4.10.8
revision=4
build_style=gnu-configure
build_wrksrc="nspr"
makedepends="zlib-devel"
short_desc="NetScape Portable Runtime"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.mozilla.org/projects/nspr/"
license="GPL-2, MPL-1.1"
distfiles="${MOZILLA_SITE}/nspr/releases/v${version}/src/${pkgname}-${version}.tar.gz"
checksum=507ea57c525c0c524dae4857a642b4ef5c9d795518754c7f83422d22fe544a15

do_configure() {
	CFLAGS="$XBPS_CFLAGS -D_PR_POLL_AVAILABLE -D_PR_HAVE_OFF64_T -D_PR_INET6 -D_PR_HAVE_INET_NTOP -D_PR_HAVE_GETHOSTBYNAME2 -D_PR_HAVE_GETADDRINFO -D_PR_INET6_PROBE"

	if [ "$CROSS_BUILD" ]; then
		_args+=" --target=$XBPS_CROSS_TRIPLET"
	fi
	case "$XBPS_TARGET_MACHINE" in
		x86_64*) _args+=" --enable-64bit";;
	esac

	./configure --build=${XBPS_TRIPLET} --prefix=/usr --libdir=/usr/lib \
		--includedir=/usr/include/nspr --enable-optimize \
		--enable-debug --enable-ipv6 ${_args}
}
do_build() {
	if [ "$CROSS_BUILD" ]; then
		make ${makejobs}
	else
		make CC=$CC CXX=$CXX ${makejobs}
	fi
}
post_install() {
	ln -s nspr.pc ${DESTDIR}/usr/lib/pkgconfig/mozilla-nspr.pc
	rm -r ${DESTDIR}/usr/bin/{compile-et.pl,prerr.properties} \
		${DESTDIR}/usr/include/nspr/md
}

nspr-devel_package() {
	depends="nspr>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/bin
		vmove usr/lib/pkgconfig
		vmove usr/share/aclocal
		vmove "usr/lib/*.a"
	}
}