SUMMARY="Yet Another JSON Library"
DESCRIPTION="A small, fast library for parsing JavaScript Object Notation \
(JSON). It supports incremental parsing from a stream and leaves data \
representation to higher level code."
HOMEPAGE="https://lloyd.github.io/yajl/"
COPYRIGHT="2007-20014 Lloyd Hilaiel, and other contributors."
LICENSE="ISC"
REVISION="3"
SOURCE_URI="https://github.com/lloyd/yajl/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="3fb73364a5a30efe615046d07e6db9d09fd2b41c763c5f7d3bfb121cd5c5ac5a"
SOURCE_DIR="yajl-$portVersion"

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

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

PROVIDES="
	libyajl${secondaryArchSuffix} = $portVersion
	cmd:json_reformat
	cmd:json_verify
	lib:libyajl$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libyajl${secondaryArchSuffix}_devel = $portVersion
	devel:libyajl$secondaryArchSuffix = $libVersionCompat
	devel:libyajl_s$secondaryArchSuffix
	"
REQUIRES_devel="
	libyajl$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

TEST_REQUIRES="
	cmd:which
	"

BUILD()
{
	mkdir -p haiku_build
	cd haiku_build

	cmake .. -DCMAKE_INSTALL_PREFIX=$prefix

	make $jobArgs
}

INSTALL()
{
	cd haiku_build

	make install

	mkdir -p "$includeDir" "$developLibDir" "$libDir"

	mv $prefix/include/yajl "$includeDir"
	mv $prefix/share/pkgconfig "$developLibDir"

	rm -rf $prefix/include
	rm -rf $prefix/share

	if [ -n "$secondaryArchSuffix" ]; then
		mv $prefix/lib/libyajl* "$libDir"/
	fi

	prepareInstalledDevelLibs libyajl libyajl_s
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$developDir"
}

TEST()
{
	cd haiku_build
	make test test-api
}
