SUMMARY="A C library for encoding, decoding and manipulating JSON data"
DESCRIPTION="Jansson is a C library for encoding, decoding and manipulating \
JSON data. It features a simple and intuitive API and data model, \
comprehensive documentation, no dependencies on other libraries, full unicode \
support (UTF-8) and an extensive test suite."
HOMEPAGE="http://www.digip.org/jansson/"
COPYRIGHT="2009-2018 Petri Lehtinen
	2011-2012 Basile Starynkevitch
	2011-2012 Graeme Smecher"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="http://www.digip.org/jansson/releases/jansson-$portVersion.tar.bz2"
CHECKSUM_SHA256="645d72cc5dbebd4df608d33988e55aa42a7661039e19a379fcbe5c79d1aee1d2"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	jansson$secondaryArchSuffix = $portVersion
	lib:libjansson$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	jansson${secondaryArchSuffix}_devel = $portVersion
	devel:libjansson$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	jansson$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:autoheader
	cmd:automake
	cmd:awk
	cmd:cmp
	cmd:diff
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:sed
	"

defineDebugInfoPackage jansson$secondaryArchSuffix \
	"$libDir"/libjansson.so.$libVersion

PATCH()
{
	if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then
		sed -i \
			-e "/AM_CFLAGS=/ s/ -Wextra//" \
			-e "/AM_CFLAGS=/ s/ -Wdeclaration-after-statement//" \
		configure.ac
	fi
}

BUILD()
{
	libtoolize --force --copy --install
	aclocal
	autoconf
	automake --add-missing
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool file
	rm $libDir/libjansson.la

	# devel package
	prepareInstalledDevelLib libjansson

	fixPkgconfig
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
