# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
pkgname=libfm
pkgver=1.3.2
pkgrel=6
pkgdesc="Library for file management"
url="https://github.com/lxde/libfm"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	dbus-glib-dev
	gtk+3.0-dev
	gtk-doc
	intltool
	libexif-dev
	menu-cache-dev
	vala
	autoconf
	automake
	libtool
	"
options="libtool"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
source="
	https://downloads.sourceforge.net/pcmanfm/libfm-$pkgver.tar.xz
	libfm-1.3.2-c99.patch
	libfm-1.3.2-buildsystem.patch
	"
prepare() {
	default_prepare
	autoreconf -vi
	update_config_guess

	# force src/actions/action.vala to be recompiled
	rm src/actions/action.c
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--disable-static \
		--with-gtk=3 \
		--with-gnu-ld

	sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	rm -rf "$pkgdir"/usr/include/libfm
	mv "$pkgdir"/usr/include/libfm-1.0/ "$pkgdir"/usr/include/libfm

	# files provided by libfm-extra for bootstrap
	rm  "$pkgdir"/usr/lib/libfm-extra.* \
		"$pkgdir"/usr/lib/pkgconfig/libfm-extra.* \
		"$pkgdir"/usr/include/libfm/fm-xml-file.h \
		"$pkgdir"/usr/include/libfm/fm-extra.h \
		"$pkgdir"/usr/include/libfm/fm-version.h
}

sha512sums="
eaa3358cd1d8f611f8f4ac882e01a716b4dc32729b641417e1100aa039db3c57ae57ccc45df7dcac4f0570cd88684beba7752a5586c1d0598b1bc7502e99f4be  libfm-1.3.2.tar.xz
a15fa0f92143d1d20b165a95ea8f68fa1f7952bed63835c87e2681ba168a1ae400d3653d56145ecf5abae4c2380ada2fbe341e3750f1fd26132e11a736977a31  libfm-1.3.2-c99.patch
d2dc9c220e2ce70c33809ecb9ce4e85529990946537970a63d60fad33577f1ec444b066abcbbf346611035e9dac5d2750ddce84105a391040c1dc8b179ec0901  libfm-1.3.2-buildsystem.patch
"
