# Template file for 'nspr'
pkgname=nspr
version=4.33
revision=1
build_wrksrc=nspr
build_style=gnu-configure
configure_args="--enable-optimize --enable-debug --enable-ipv6"
makedepends="zlib-devel"
short_desc="NetScape Portable Runtime"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="MPL-2.0"
homepage="http://www.mozilla.org/projects/nspr/"
distfiles="${MOZILLA_SITE}/nspr/releases/v${version}/src/${pkgname}-${version}.tar.gz"
checksum=b23ee315be0e50c2fb1aa374d17f2d2d9146a835b1a79c1918ea15d075a693d7
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 [ "$XBPS_TARGET_WORDSIZE" = 64 ]; then
	configure_args+=" --enable-64bit"
fi

if [ "$CROSS_BUILD" ]; then
	# nspr misused host in place of build
	configure_args+=" --host=$XBPS_TRIPLET --target=$XBPS_CROSS_TRIPLET"
	export HOST_CC="$CC_FOR_BUILD"
	export HOST_CFLAGS="$CFLAGS_FOR_BUILD"
	export HOST_LDFLAGS="$LDFLAGS_FOR_BUILD"
fi

post_install() {
	sed -i "s|\(-specs=.*hardened-ld\)||g" ${DESTDIR}/usr/bin/nspr-config
	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"
	}
}
