SUMMARY="A library for building efficient parsers"
DESCRIPTION="LibParserUtils is a library for building efficient parsers."
HOMEPAGE="https://www.netsurf-browser.org/projects/libparserutils/"
COPYRIGHT="2007-2018 J-M Bell"
LICENSE="MIT"
REVISION="2"
SOURCE_URI="https://download.netsurf-browser.org/libs/releases/libparserutils-$portVersion-src.tar.gz"
CHECKSUM_SHA256="322bae61b30ccede3e305bf6eae2414920649775bc5ff1d1b688012a3c4947d8"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	libparserutils$secondaryArchSuffix = $portVersion
	lib:libparserutils$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv${secondaryArchSuffix}
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv${secondaryArchSuffix}
	lib:libiconv${secondaryArchSuffix}
	"
BUILD_PREREQUIRES="
	netsurf_buildsystem
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:perl
	"

BUILD()
{
	# Build the static lib
	CFLAGS=-Wno-error make PREFIX=$prefix NSSHARED=/system/data/netsurf-buildsystem
	# Build the shared lib
	CFLAGS=-Wno-error make PREFIX=$prefix NSSHARED=/system/data/netsurf-buildsystem \
		COMPONENT_TYPE=lib-shared
}

INSTALL()
{
	make install PREFIX=$prefix NSSHARED=/system/data/netsurf-buildsystem \
		INCLUDEDIR=$relativeIncludeDir LIBDIR=$relativeLibDir
	make install PREFIX=$prefix NSSHARED=/system/data/netsurf-buildsystem \
		INCLUDEDIR=$relativeIncludeDir LIBDIR=$relativeLibDir COMPONENT_TYPE=lib-shared

	prepareInstalledDevelLib libparserutils
	fixPkgconfig

	packageEntries devel $developDir
}

TEST()
{
	make PREFIX=$prefix NSSHARED=/system/data/netsurf-buildsystem \
		LDFLAGS=-liconv test
}
