SUMMARY="Internationalized Domain Names (IDN) implementation"
DESCRIPTION="Libidn2 is a free software implementation of IDNA2008, Punycode \
and TR46. Its purpose is to encode and decode internationalized domain names."
HOMEPAGE="https://www.gnu.org/software/libidn/#libidn2"
COPYRIGHT="2011-2018 Simon Josefsson"
LICENSE="GNU GPL v2
	GNU GPL v3
	GNU LGPL v3"
REVISION="2"
SOURCE_URI="https://ftpmirror.gnu.org/libidn/libidn2-$portVersion.tar.gz
	https://ftp.gnu.org/gnu/libidn/libidn2-$portVersion.tar.gz"
CHECKSUM_SHA256="53f69170886f1fa6fa5b332439c7a77a7d22626a82ef17e2c1224858bb4ca2b8"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	libidn2$secondaryArchSuffix = $portVersion
	lib:libidn2$secondaryArchSuffix = $libVersionCompat
	cmd:idn2$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:autoheader
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:makeinfo
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libidn2$secondaryArchSuffix \
	$commandBinDir/idn2 \
	$libDir/libidn2.so.$libVersion

BUILD()
{
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure --bindir $commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install

	rm -f $libDir/libidn2.la
	rm -f $libDir/charset.alias
	rm -f $infoDir/dir

	prepareInstalledDevelLib libidn2
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir \
		$infoDir \
		$manDir/man3
}

TEST()
{
	make check
}
