# libfm - File management library for LXDE
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=libfm
version=1.3.2
release=1
desc="File management library for LXDE"
url="https://lxde.org/"
license="GPL-2.0-or-later"
depend="glibc glib gtk3 menu-cache"
makedepend=""
source="https://downloads.sourceforge.net/pcmanfm/libfm-1.3.2.tar.xz"
sha256="SKIP"

build() {
	# LXDE's GTK code predates clang treating an incompatible pointer
	# assignment as an error rather than a warning. The assignments are the
	# usual GTK widget-to-subclass ones and upstream has not moved.
	export CFLAGS="$CFLAGS -fcommon -Wno-incompatible-pointer-types -Wno-int-conversion"
	cd "libfm-1.3.2"
	# Not every configure script accepts the same options - sqlite rejects
	# --disable-nls outright, for instance - so only pass the ones this one
	# actually advertises. Guessing wrong fails the whole build.
	_opts="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib"
	_help=$(./configure --help 2>/dev/null)
	case "$_help" in *--disable-static*)  _opts="$_opts --disable-static" ;; esac
	case "$_help" in *--disable-nls*)     _opts="$_opts --disable-nls" ;; esac
	# LXDE still defaults to GTK2, which ScrapLinux does not have and is not
	# going to package. Every one of these builds against GTK3 when asked.
	case "$_help" in *--with-gtk*) _opts="$_opts --with-gtk=3" ;; esac
	# shellcheck disable=SC2086
	./configure $_opts
	# src/modules is five small optional GIO extensions (trash/shortcut
	# context-menu items, a search vfs backend) - not linked by pcmanfm or
	# lxpanel, loaded at runtime through GIO's own module system if present
	# at all. Every one of them hits the same multilib linker trap other
	# autotools -module targets on this host do: libtool's own -L for a
	# `-module` target reaches the host's 32-bit /usr/lib ahead of the
	# 64-bit one lld needs, in a way that survives -B/usr/lib64 and
	# LIBRARY_PATH both, because libtool does not carry either through to
	# a module link. Losing five right-click menu items is a fair trade for
	# a libfm that actually builds; dropped from SUBDIRS so make never
	# descends into that directory at all.
	sed -i '/^\tmodules \\$/d' src/Makefile
	make -j"$JOBS"
}

package() {
	cd "libfm-1.3.2"
	make DESTDIR="$pkgdir" install
}
