SUMMARY="An encoding detector library ported from Mozilla"
DESCRIPTION="uchardet is an encoding detector library, which takes a sequence \
of bytes in an unknown character encoding without any additional information, \
and attempts to determine the encoding of the text. Returned encoding names \
are iconv-compatible.
uchardet started as a C language binding of the original C++ implementation of \
the universal charset detection library by Mozilla. It can now detect more \
charsets, and more reliably than the original implementation."
HOMEPAGE="https://www.freedesktop.org/wiki/Software/uchardet/"
COPYRIGHT="2015-2016 BYVoid, Jehan"
LICENSE="MPL v1.1"
REVISION="1"
SOURCE_URI="https://www.freedesktop.org/software/uchardet/releases/uchardet-$portVersion.tar.xz"
CHECKSUM_SHA256="3fc79408ae1d84b406922fa9319ce005631c95ca0f34b205fad867e8b30e45b1"
PATCHES="uchardet-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	uchardet$secondaryArchSuffix = $portVersion
	lib:libuchardet$secondaryArchSuffix = $portVersion compat >= 0
	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
		cmd:uchardet
		"
fi

REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	uchardet${secondaryArchSuffix}_devel = $portVersion
	devel:libuchardet$secondaryArchSuffix = $portVersion compat >= 0
	"
REQUIRES_devel="
	uchardet$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	cmake . \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_INSTALL_BINDIR=$binDir \
		-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
		-DCMAKE_INSTALL_LIBDIR=$libDir \
		-DCMAKE_INSTALL_MANDIR=$manDir \
		-DCMAKE_BUILD_TYPE=Release
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libuchardet.a

	prepareInstalledDevelLibs libuchardet
	fixPkgconfig

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $binDir
		rm -rf $documentationDir
	fi

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make test
}
