SUMMARY="GNU tools for native language support"
DESCRIPTION="
GNU 'gettext' is an important step for the GNU Translation Project, as it is \
an asset on which we may build many other steps. This package offers to \
programmers, translators, and even users, a well integrated set of tools and \
documentation. Specifically, the GNU 'gettext' utilities are a set of tools \
that provides a framework to help other GNU packages produce multi-lingual \
messages. These tools include a set of conventions about how programs should \
be written to support message catalogs, a directory and file naming \
organization for the message catalogs themselves, a runtime library supporting \
the retrieval of translated messages, and a few stand-alone programs to \
massage in various ways the sets of translatable strings, or already \
translated strings. A special GNU Emacs mode also helps interested parties in \
preparing these sets, or bringing them up to date.
"
HOMEPAGE="http://www.gnu.org/software/gettext/"
LICENSE="GNU GPL v3"
COPYRIGHT="1998, 2010 Free Software Foundation, Inc."
SRC_URI="http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz"
CHECKSUM_SHA256="93ac71a7afa5b70c1b1032516663658c51e653087f42a3fc8044752c026443e9"
REVISION="5"
ARCHITECTURES="x86_gcc2 x86 x86_64 arm"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PATCHES="gettext-0.18.1.1.patch"

PROVIDES="
	gettext$secondaryArchSuffix = $portVersion compat >= 0.18.1
	devel:libasprintf$secondaryArchSuffix = 0.0.0 compat >= 0
	devel:libgettextlib$secondaryArchSuffix = $portVersion
	devel:libgettextlib_0.18.1$secondaryArchSuffix = $portVersion
	devel:libgettextpo$secondaryArchSuffix = 0.5.1 compat >= 0
	devel:libgettextsrc$secondaryArchSuffix = $portVersion
	devel:libgettextsrc_0.18.1$secondaryArchSuffix = $portVersion
	devel:libintl$secondaryArchSuffix = 8.1.1 compat >= 8
	lib:libasprintf$secondaryArchSuffix = 0.0.0 compat >= 0
	lib:libgettextlib_0.18.1$secondaryArchSuffix = $portVersion
	lib:libgettextpo$secondaryArchSuffix = 0.5.1 compat >= 0
	lib:libgettextsrc_0.18.1$secondaryArchSuffix = $portVersion
	cmd:autopoint$secondaryArchSuffix
	cmd:envsubst$secondaryArchSuffix
	cmd:gettext$secondaryArchSuffix
	cmd:gettext.sh$secondaryArchSuffix
	cmd:gettextize$secondaryArchSuffix
	cmd:msgattrib$secondaryArchSuffix
	cmd:msgcat$secondaryArchSuffix
	cmd:msgcmp$secondaryArchSuffix
	cmd:msgcomm$secondaryArchSuffix
	cmd:msgconv$secondaryArchSuffix
	cmd:msgen$secondaryArchSuffix
	cmd:msgexec$secondaryArchSuffix
	cmd:msgfilter$secondaryArchSuffix
	cmd:msgfmt$secondaryArchSuffix
	cmd:msggrep$secondaryArchSuffix
	cmd:msginit$secondaryArchSuffix
	cmd:msgmerge$secondaryArchSuffix
	cmd:msgunfmt$secondaryArchSuffix
	cmd:msguniq$secondaryArchSuffix
	cmd:ngettext$secondaryArchSuffix
	cmd:recode_sr_latin$secondaryArchSuffix
	cmd:xgettext$secondaryArchSuffix

	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
		cmd:autopoint = $portVersion compat >= 0
		cmd:envsubst = $portVersion compat >= 0
		cmd:gettext = $portVersion compat >= 0
		cmd:gettext.sh = $portVersion compat >= 0
		cmd:gettextize = $portVersion compat >= 0
		cmd:msgattrib = $portVersion compat >= 0
		cmd:msgcat = $portVersion compat >= 0
		cmd:msgcmp = $portVersion compat >= 0
		cmd:msgcomm = $portVersion compat >= 0
		cmd:msgconv = $portVersion compat >= 0
		cmd:msgen = $portVersion compat >= 0
		cmd:msgexec = $portVersion compat >= 0
		cmd:msgfilter = $portVersion compat >= 0
		cmd:msgfmt = $portVersion compat >= 0
		cmd:msggrep = $portVersion compat >= 0
		cmd:msginit = $portVersion compat >= 0
		cmd:msgmerge = $portVersion compat >= 0
		cmd:msgunfmt = $portVersion compat >= 0
		cmd:msguniq = $portVersion compat >= 0
		cmd:ngettext = $portVersion compat >= 0
		cmd:recode_sr_latin = $portVersion compat >= 0
		cmd:xgettext = $portVersion compat >= 0
		"
fi

REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	gettext${secondaryArchSuffix}_libintl == $portVersion base
	lib:libiconv$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	"
BUILD_REQUIRES="
	devel:libiconv$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	cmd:makeinfo
	"

BUILD()
{
	libtoolize --force --copy --install
	./autogen.sh --quick --skip-gnulib
	runConfigure ./configure \
		--disable-java --without-git
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/charset.alias

	prepareInstalledDevelLibs libasprintf libgettextpo libintl
	prepareInstalledDevelLib libgettextlib '*.so' '*'
	prepareInstalledDevelLib libgettextsrc '*.so' '*'

	# libintl package
	packageEntries libintl \
		$libDir/libintl*
}

TEST()
{
	cd gettext-runtime/tests
	make check
}

# ----- libintl package -------------------------------------------------------

SUMMARY_libintl="The gettext internationalization library"
PROVIDES_libintl="
	gettext${secondaryArchSuffix}_libintl = $portVersion compat >= 0.18.1
	lib:libintl${secondaryArchSuffix} = 8.1.1 compat >= 8
	"
REQUIRES_libintl="
	haiku${secondaryArchSuffix} >= $haikuVersion
	lib:libiconv${secondaryArchSuffix}
	"
