SUMMARY="A library for manipulating Unicode strings"
DESCRIPTION="libunistring provides functions for manipulating Unicode strings \
and for manipulating C strings according to the Unicode standard."
HOMEPAGE="https://www.gnu.org/software/libunistring/"
COPYRIGHT="1998-2018 Free Software Fundation, Inc."
LICENSE="GNU GPL v2
	GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://ftpmirror.gnu.org/libunistring/libunistring-$portVersion.tar.gz
	https://ftp.gnu.org/gnu/libunistring/libunistring-$portVersion.tar.gz"
CHECKSUM_SHA256="a82e5b333339a88ea4608e4635479a1cfb2e01aafb925e1290b65710d43f610b"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	libunistring$secondaryArchSuffix = $portVersionCompat
	lib:libunistring$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:gperf
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage libunistring$secondaryArchSuffix \
	"$libDir"/libunistring.so.$libVersion

BUILD()
{
	autoreconf -fi
	if [ -n "$secondaryArchSuffix" ]; then
		runConfigure ./configure
	else
		runConfigure --omit-dirs docDir ./configure --docdir="$developDocDir"
	fi
	make $jobArgs
}

INSTALL()
{
	make install
	rm -f "$libDir"/libunistring.la "$libDir"/charset.alias

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf "$documentationDir"
		maybe_infoDir=
	else
		install -t "$developDocDir" README
		maybe_infoDir="$infoDir"
	fi

	prepareInstalledDevelLib libunistring
	packageEntries devel \
		"$developDir" \
		${maybe_infoDir:+"$maybe_infoDir"}
}

TEST()
{
	make check
}
