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.
"
LICENSE="
GNU GPL v2
GNU LGPL v2.1
MPL v2.0
"
COPYRIGHT="Mozilla Foundation"
HOMEPAGE="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR"
SOURCE_URI="https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v$portVersion/src/nspr-$portVersion.tar.gz"
CHECKSUM_SHA256="507ea57c525c0c524dae4857a642b4ef5c9d795518754c7f83422d22fe544a15"
REVISION="1"
ARCHITECTURES="x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
    # x86_gcc2 is fine as primary target architecture as long as we're building
    # for a different secondary architecture.
    ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"
SOURCE_DIR="nspr-$portVersion/nspr"

PATCHES="nspr-$portVersion.patchset"

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
	"
BUILD_REQUIRES="
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:autoconf
	cmd:aclocal
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:awk
	cmd:perl
	"

BUILD()
{
	if [ $effectiveTargetArchitecture == 'x86_64' ]; then
		use64bits="--enable-64bit"
	fi
	autoreconf -fi
	runConfigure ./configure --disable-debug --enable-optimize \
		$use64bits
	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

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

TEST()
{
	autoconf
	runConfigure ./configure
	cd pr/tests
	make $jobArgs
	make runtests
}

# ----- devel package -------------------------------------------------------

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
	"
