SUMMARY="A unit testing framework for C"
DESCRIPTION="cmocka is an elegant unit testing framework for C with support \
for mock objects. It only requires the standard C library, works on a range \
of computing platforms (including embedded) and with different compilers."
HOMEPAGE="https://cmocka.org/"
COPYRIGHT="2008 Google Inc.
	2014-2018 Andreas Schneider
	2015 Jakub Hrozek"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="https://cmocka.org/files/${portVersion%.*}/cmocka-$portVersion.tar.xz"
CHECKSUM_SHA256="f0ccd8242d55e2fd74b16ba518359151f6f8383ff8aef4976e48393f77bba8b6"
PATCHES="cmocka-$portVersion.patchset"

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

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

PROVIDES="
	cmocka$secondaryArchSuffix = $portVersion
	lib:libcmocka$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	cmocka${secondaryArchSuffix}_devel = $portVersion
	devel:libcmocka$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	cmocka$secondaryArchSuffix == $portVersion base
	haiku${secondaryArchSuffix}_devel
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage cmocka$secondaryArchSuffix \
	"$libDir"/libcmocka.so.$libVersion

BUILD()
{
	mkdir -p build
	cd build

	cmake .. \
		$cmakeDirArgs \
		-DINCLUDE_INSTALL_DIR="$includeDir" \
		-DLIBEXEC_INSTALL_DIR="$libDir" \
		-DLIB_INSTALL_DIR="$libDir"

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLib libcmocka
	fixPkgconfig

	packageEntries devel \
		"$developDir" \
		"$libDir"/cmake
}

TEST()
{
	cd build
	make test
}
