# Template file for 'gettext'
pkgname=gettext
version=0.21
revision=2
build_style=gnu-configure
configure_args="--disable-java --disable-native-java --disable-csharp
 --disable-libasprintf --enable-threads=posix --disable-rpath --without-emacs
 --disable-acl --with-included-glib --with-included-libcroco --without-git
 --with-included-libxml --with-included-libunistring --disable-openmp
 --disable-curses --without-examples --enable-nls
 gl_cv_func_gettimeofday_clobber=no"
# gettext will try to use xz bzip2 gzip to compress
# /usr/share/gettext/archive.dir.tar.<ext>
# Either:
# - Have xz in hostmakedepends; or
# - Let gettext-devel depends on bzip2
hostmakedepends="xz"
short_desc="Internationalized Message Handling Library and tools"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="GPL-3.0-or-later"
homepage="https://www.gnu.org/software/gettext/"
changelog="https://git.savannah.gnu.org/cgit/gettext.git/plain/NEWS"
distfiles="${GNU_SITE}/${pkgname}/${pkgname}-${version}.tar.gz"
checksum=c77d0da3102aec9c07f43671e60611ebff89a996ef159497ce8e59d075786b12

case "$XBPS_TARGET_MACHINE" in
	# force libintl
	*-musl) configure_args+=" --with-included-gettext";;
esac

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" automake libtool"
	pre_configure() {
		autoreconf -fi
	}
fi


post_install() {
	# Fix conflict with musl.
	if [ -e ${DESTDIR}/usr/include/libintl.h ]; then
		vmkdir usr/include/gettext
		mv ${DESTDIR}/usr/include/libintl.h ${DESTDIR}/usr/include/gettext/libintl.h
	fi
}

gettext-devel-examples_package() {
	short_desc+=" - examples for development"
	pkg_install() {
		vmove usr/share/doc/gettext
	}
}
gettext-devel_package() {
	depends="gettext-libs>=${version}_${revision} xz tar"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.a
		vmove usr/share/aclocal
		vmove usr/share/gettext
		vmove usr/share/man/man3
		vmove usr/bin/autopoint
		vmove usr/bin/gettextize
	}
}
gettext-libs_package() {
	short_desc+=" - shared libraries"
	pkg_install() {
		vmove usr/lib/*.so*
	}
}
