SUMMARY="A simple C/C++ configuration file library"
DESCRIPTION="Libconfig is a simple library for processing structured \
configuration files. Libconfig is very compact, a fraction of the size of the \
expat XML parser library. This makes it well-suited for memory constrained \
systems like handheld devices."
HOMEPAGE="https://www.hyperrealm.com/libconfig/"
COPYRIGHT="2005-2018 Mark A Lindner"
LICENSE="GNU LGPL v3"
REVISION="2"
SOURCE_URI="https://github.com/hyperrealm/libconfig/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="f67ac44099916ae260a6c9e290a90809e7d782d96cdd462cac656ebc5b685726"
SOURCE_FILENAME="libconfig-$portVersion.tar.gz"

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

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

PROVIDES="
	libconfig$secondaryArchSuffix = $portVersion
	lib:libconfig$secondaryArchSuffix = $libVersionCompat
	lib:libconfig++$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libconfig${secondaryArchSuffix}_devel = $portVersion
	devel:libconfig$secondaryArchSuffix = $libVersionCompat
	devel:libconfig++$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libconfig$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:automake
	cmd:autoreconf
	cmd:bison
	cmd:flex
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libconfig$secondaryArchSuffix \
	"$libDir"/libconfig.so.$libVersion \
	"$libDir"/libconfig++.so.$libVersion

BUILD()
{
	autoreconf -fi
	MAKEINFO=true runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool files
	rm -f $libDir/libconfig*.la

	prepareInstalledDevelLibs libconfig libconfig++
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$developDir" \
		"$libDir"/cmake

	rmdir "$infoDir"
}

TEST()
{
	make check test
}
