SUMMARY="A CSS parser and selection engine"
DESCRIPTION="LibCSS is a CSS (Cascading Style Sheet) parser and selection \
engine."
HOMEPAGE="https://www.netsurf-browser.org/projects/libcss/"
COPYRIGHT="2007-2018 The NetSurf Developers"
LICENSE="MIT"
REVISION="3"
SOURCE_URI="https://download.netsurf-browser.org/libs/releases/libcss-$portVersion-src.tar.gz"
CHECKSUM_SHA256="d2dce16e93392e8d6a7209420d47c2d56a3811701a0e81a724fc541c63d3c6dc"

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

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

PROVIDES="
	libcss$secondaryArchSuffix = $portVersion
	lib:libcss$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libparserutils$secondaryArchSuffix
	lib:libwapcaplet$secondaryArchSuffix
	"

PROVIDES_devel="
	libcss${secondaryArchSuffix}_devel = $portVersion
	devel:libcss$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libcss$secondaryArchSuffix == $portVersion base
	devel:libwapcaplet$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libparserutils$secondaryArchSuffix >= 0.2.4
	devel:libwapcaplet$secondaryArchSuffix >= 0.4.3
	"
BUILD_PREREQUIRES="
	netsurf_buildsystem >= 1.9
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libcss$secondaryArchSuffix $libDir/libcss.so.$libVersion

BUILD()
{
	make PREFIX="$prefix" NSSHARED=/system/data/netsurf-buildsystem \
		COMPONENT_TYPE=lib-shared VARIANT=debug
}

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

	prepareInstalledDevelLib libcss
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$developDir"
}

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