SUMMARY="Library providing GLib serialization and deserialization for the JSON format"
DESCRIPTION="JSON-GLib is a library providing serialization and deserialization support \
for the JavaScript Object Notation (JSON) format described by RFC 4627.

Many high-level languages already provide native modules for parsing, generating and \
manipulating JSON data streams.

JSON-GLib is a C library based on GLib and released under the terms of the GNU Lesser \
General Public License version 2.1. It provides a parser and a generator GObject \
classes and various wrappers for the complex data types employed by JSON, such as arrays and objects.

JSON-GLib uses GLib native data types and the generic value container GValue for ease of development. \
It also provides integration with the GObject classes for direct serialization into, and \
deserialization from, JSON data streams."
HOMEPAGE="https://gitlab.gnome.org/GNOME/json-glib"
COPYRIGHT="2007, 2008 OpenedHand Ltd
2009-2012 Intel Corp.
2013 Emmanuele Bassi"
LICENSE="GNU LGPL v2.1"
REVISION="3"
SOURCE_URI="https://download.gnome.org/sources/json-glib/${portVersion%.*}/json-glib-$portVersion.tar.xz"
CHECKSUM_SHA256="720c5f4379513dc11fd97dc75336eb0c0d3338c53128044d9fabec4374f4bc47"
SOURCE_DIR="json-glib-$portVersion"

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

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

PROVIDES="
	json_glib$secondaryArchSuffix = $portVersionCompat
	lib:libjson_glib_1.0$secondaryArchSuffix = $libVersionCompat
	cmd:json_glib_format$secondaryArchSuffix = $portVersion
	cmd:json_glib_validate$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgio_2.0$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgobject_2.0$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	"

PROVIDES_devel="
	json_glib${secondaryArchSuffix}_devel = $portVersionCompat
	devel:libjson_glib_1.0$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	json_glib$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgio_2.0$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libgobject_2.0$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:gcc$secondaryArchSuffix
	cmd:meson
	cmd:ninja
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	"

BUILD()
{
	meson \
		--buildtype=debugoptimized \
		--prefix=$prefix \
		--bindir=$binDir \
		--libdir=$libDir \
		--includedir=$includeDir \
		--datadir=$dataDir \
		--mandir=$manDir \
		--localedir=$dataDir/locale \
		--libexecdir=$binDir \
		_build
	ninja -C _build
}

INSTALL()
{
	ninja -C _build install
	rm -rf $binDir/installed-tests $dataDir/installed-tests

	prepareInstalledDevelLib libjson-glib-1.0
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	meson test -C _build
}
