### this file is sourced not run
PKGVER=2.74.5
PKGBUILD=1
PKGARCH=i686

# source: BLFS 11.3
TARBALL=glib-$PKGVER.tar.xz
MD5SUM=7561501d9f63f3418ddb23d2903cc968
SRC_URL=https://download.gnome.org/sources/glib/2.74/$TARBALL
BUNDLE=

SLACKREQ='libffi32 libpcre32 libattr32 dbus32'
SLACKDESC="glib32: glib32 $PKGVER (GTK low-level library)  
glib32:  
glib32: The GLib package contains a low-level libraries useful for providing 
glib32: data structure handling for C, portability wrappers and interfaces for 
glib32: such runtime functionality as an event loop, threads, dynamic loading 
glib32: and an object system.  
glib32: 
glib32: This contains the 32-bit version of the library.
glib32: 
glib32: 
glib32:
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/glib* &&

	# BLFS 11.3 patch to suppress warnings
	patch -Np1 -i ../pkg/glib-2.74.5-skip_warnings-1.patch &&

	# Show /mnt and work without GVFS
	patch -Np1 -i ../pkg/jemimah-glib-patches-2.74.5.patch &&

	# allow bind mounts to show
	patch -Np1 -i ../pkg/allow-bind-mount-2.74.5.patch &&
	
	# fix bug - fixed in upstream already?
	# patch -Np1 -i ../pkg/user-mountable-detect-bug.patch &&

	# new strict enforcement of gparam_spec_is_valid_name crashes many non-compliant old apps
	# so disable it
	patch -Np1 -i ../pkg/dont-crash-on-gparam-spec-invalid-name.patch &&

	true
}

### default pkg_prepare
pkg_package() {
	rm -rf bin sbin usr/bin usr/sbin usr/include usr/share 
}

### build
pkg_build() {
	cd /tmp/glib* &&

	export LANG=en_US.utf8 # this is required by python3, which is used by gtk-doc
	export CFLAGS="$CFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CAST_CHECKS -DNDEBUG"

	# The old autoconf way
<< "EOF"
    NM=nm
	CONFFLAGS="$CONFFLAGS --with-pcre=system --host ${CLFS_TARGET32}
		--disable-libmount" # glib's own parsing code is good. No need libmount.
	
	NOCONFIGURE=yes ./autogen.sh &&
	pkg_build_autoconf &&
EOF

	# The new meson/ninja way
	
	# james patch 2.74.5 - doc: kill gdbus_example when we build without tests
	sed -i -e '/gdbus.*example/ s/^/#/' docs/reference/gio/meson.build &&
	# appease gcc 12.2.x
	CFLAGS="$CFLAGS -Wno-declaration-after-statement" &&
	
	MESONFLAGS="$MESONFLAGS \
		--buildtype=release \
		-Dlibmount=disabled \
		-Dtests=false       \
		-Dglib_assert=false \
	" &&
	pkg_build_meson &&

	pkg_build_slackdesc
}


