SUMMARY="A unit testing framework for C"
DESCRIPTION="A lightweight system for writing, administering, and running unit \
tests in C."
HOMEPAGE="https://github.com/BelledonneCommunications/bcunit"
COPYRIGHT="2017 BCUnit Authors"
LICENSE="GNU LGPL v2"
REVISION="1"
SOURCE_URI="https://github.com/BelledonneCommunications/bcunit/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="eb7090aca5006aa0cea425722cb3fa1a7139185a7d9d1734d57844f69084713f"
PATCHES="bcunit-$portVersion.patchset"

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

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

PROVIDES="
	bcunit$secondaryArchSuffix = $portVersion
	lib:libbcunit$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	bcunit${secondaryArchSuffix}_devel = $portVersion
	devel:libbcunit$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	bcunit$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	./autogen.sh
	runConfigure ./configure --enable-test
	make $jobArgs
}

INSTALL()
{
	make install

	install -d -m 755 "$docDir" "$developDocDir"
	mv "$prefix/doc/BCUnit/"* "$developDocDir/"
	rm -rf "$prefix/doc"

	install -t "$docDir" -m 644 AUTHORS

	# No need to install internal test suite
	rm -rf "$dataDir/BCUnit/Test"

	# libtool
	rm -f "$libDir/"*.la

	prepareInstalledDevelLib libbcunit
	fixPkgconfig
	packageEntries devel \
		"$developDir" \
		"$manDir"
}

TEST()
{
	./BCUnit/Sources/Test/test_bcunit
}
