# Template file for 'libglib-static'
#
# This is only used for qemu-user-static until meson figures out building static
# glib 2.60.0 via meson.
#
pkgname=libglib-static
version=2.58.3
revision=5
wrksrc="glib-${version}"
build_style=gnu-configure
configure_args="--enable-libelf --disable-fam --disable-shared --with-pcre=system
 --enable-static"
hostmakedepends="automake gettext libtool pkg-config python3 libxslt docbook-xsl"
makedepends="zlib-devel pcre-devel libffi-devel dbus-devel elfutils-devel libmount-devel"
depends="$makedepends"
short_desc="GNU library of C routines"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="LGPL-2.1-or-later"
homepage="https://wiki.gnome.org/Projects/GLib"
changelog="https://gitlab.gnome.org/GNOME/glib/raw/master/NEWS"
distfiles="${GNOME_SITE}/glib/${version%.*}/glib-${version}.tar.xz"
checksum=8f43c31767e88a25da72b52a40f3301fefc49a665b56dc10ee7cc9565cbe7481
conflicts="libglib-devel>=0"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" glib-devel"
	case "$XBPS_TARGET_MACHINE" in
		mips*|ppc|ppc-musl)	# It seems mips/ppc autoconf cache is not read?
			configure_args+=" glib_cv_stack_grows=no glib_cv_rtldglobal_broken=no glib_cv_uscore=no" ;;
	esac
fi

post_patch() {
	# Better to just rm -rf /usr/lib/locale in post_install?
	vsed -i -e "s,localedir=.*,localedir=/usr/share/locale," \
		-e "s,DATADIRNAME=lib,DATADIRNAME=share," \
		m4macros/glib-gettext.m4
	vsed -i -e "s,^localedir =.*,localedir = /usr/share/locale," \
		po/Makefile.in.in
}

pre_configure() {
	NOCONFIGURE=1 ./autogen.sh
}

post_install() {
	rm -r $DESTDIR/usr/bin
	rm -r $DESTDIR/usr/share
}
