SUMMARY="NetSurf generalised utility library"
DESCRIPTION="Various things useful to the NetSurf browser, and possibly to \
other applications."
HOMEPAGE="https://git.netsurf-browser.org/libnsutils.git/"
COPYRIGHT="2014-2020 Vincent Sanders"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://download.netsurf-browser.org/libs/releases/libnsutils-$portVersion-src.tar.gz"
CHECKSUM_SHA256="790c6516344abe82f6289d656392e9ccebe475b20cc7e1e2d843011385f7aef0"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	libnsutils$secondaryArchSuffix = $portVersion
	lib:libnsutils$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libnsutils${secondaryArchSuffix}_devel = $portVersion
	devel:libnsutils$secondaryArchSuffix = $libVersion compat = $libVersionCompat
	"
REQUIRES_devel="
	libnsutils$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	netsurf_buildsystem >= 1.9
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	for linkage in lib-static lib-shared; do
		make PREFIX="$prefix" NSSHARED=/system/data/netsurf-buildsystem \
			COMPONENT_TYPE=$linkage
	done
}

INSTALL()
{
	for linkage in lib-static lib-shared; do
		make PREFIX="$prefix" NSSHARED=/system/data/netsurf-buildsystem \
			COMPONENT_TYPE=$linkage \
			INCLUDEDIR=$relativeIncludeDir LIBDIR=$relativeLibDir \
			install
	done

	prepareInstalledDevelLib libnsutils
	fixPkgconfig

	packageEntries devel \
		"$developDir"
}
