SUMMARY="A platform abstraction library"
DESCRIPTION="Netscape Portable Runtime (NSPR) provides a platform-neutral \
API for system level and libc-like functions. The API is used in the \
Mozilla clients, many of Red Hat's and Sun's server applications, and \
other software offerings."
HOMEPAGE="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR"
COPYRIGHT="Mozilla Foundation"
LICENSE="GNU GPL v2
	GNU LGPL v2.1
	MPL v2.0
	"
REVISION="2"
SOURCE_URI="https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v$portVersion/src/nspr-$portVersion.tar.gz"
CHECKSUM_SHA256="b23ee315be0e50c2fb1aa374d17f2d2d9146a835b1a79c1918ea15d075a693d7"
SOURCE_DIR="nspr-$portVersion/nspr"
PATCHES="nspr-$portVersion.patchset"
if [ $effectiveTargetArchitecture == 'x86' ]; then
		PATCHES="$PATCHES
		nspr_x86-$portVersion.patchset"
fi

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	nspr$secondaryArchSuffix = $portVersion
	lib:libnspr4$secondaryArchSuffix = $portVersion compat >= 4
	lib:libplc4$secondaryArchSuffix = $portVersion compat >= 4
	lib:libplds4$secondaryArchSuffix = $portVersion compat >= 4
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	nspr${secondaryArchSuffix}_devel = $portVersion compat >= 4
	cmd:nspr_config$secondaryArchSuffix = $portVersion compat >= 4
	devel:libnspr4$secondaryArchSuffix = $portVersion compat >= 4
	devel:libplc4$secondaryArchSuffix = $portVersion compat >= 4
	devel:libplds4$secondaryArchSuffix = $portVersion compat >= 4
	"
REQUIRES_devel="
	nspr${secondaryArchSuffix} == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:perl
	"

BUILD()
{
	if [ "$effectiveTargetArchitecture" = x86_64 ]; then
		use64Bits="--enable-64bit"
	fi
	autoreconf -fi
	runConfigure --omit-dirs "includedir" ./configure --disable-debug --enable-optimize \
		$use64Bits --includedir=$includeDir/nspr
	make $jobArgs
}

INSTALL()
{
	make install

	# set up the develop directory correctly
	prepareInstalledDevelLibs libnspr4 libplc4 libplds4
	fixPkgconfig

	rm $binDir/compile-et.pl
	rm $binDir/prerr.properties
	rm -r $includeDir/nspr/md

	# devel package
	packageEntries devel \
		$developDir \
		$dataDir/aclocal \
		$binDir/nspr-config
}

TEST()
{
	if [ "$effectiveTargetArchitecture" = x86_64 ]; then
		use64Bits="--enable-64bit"
	fi
	autoconf
	runConfigure ./configure $use64Bits
	cd pr/tests
	make $jobArgs
	make runtests
}
