# Template file for 'geany-plugins'
pkgname=geany-plugins
version=2.0
revision=2
build_style=gnu-configure
configure_args="--enable-all-plugins
 --disable-geniuspaste --disable-updatechecker --disable-debugger"
hostmakedepends="automake gettext-devel intltool libtool pkg-config vala
 glib-devel"
makedepends="geany-devel lua51-devel ctpl-devel zlib-devel
 gpgme-devel enchant2-devel libgit2-devel
 gtkspell-devel libwebkit2gtk41-devel vte3-devel"
short_desc="Geany IDE plugins"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="http://plugins.geany.org"
changelog="https://raw.githubusercontent.com/geany/geany-plugins/master/NEWS"
distfiles="https://download.geany.org/geany-plugins/geany-plugins-${version}.tar.gz"
checksum=cd7d27f00aef4afe2040d7e5246a863234c340c8520ef698be9a15005ed8f57e

post_patch() {
	# Use libwebkit2gtk41, cannot be used with updatechecker or geniuspaste
	# See: https://github.com/geany/geany-plugins/issues/1302#issuecomment-1925011272
	vsed -e 's/webkit2gtk-4.0/webkit2gtk-4.1/' -i build/markdown.m4
	vsed -e 's/webkit2gtk-4.0/webkit2gtk-4.1/' -i build/webhelper.m4
}

pre_configure() {
	autoreconf -fi
}

pre_build() {
	# XXX: Compile 'leg' for host arch.
	make CC=cc CFLAGS="-fPIE" -C "markdown/peg-markdown/peg-0.1.9"
}

# These plugins require extra dependencies
geany-plugins-extra_package() {
	short_desc+=" - extra plugins"
	pkg_install() {
		for p in geanygendoc geanylua geanypg geniuspaste \
			git-changebar pretty-printer spellcheck; do
			if [ -x ${DESTDIR}/usr/lib/geany/${p}.so ]; then
				vmove usr/lib/geany/${p}.so
			fi
			if [ -x ${DESTDIR}/usr/share/geany-plugins/${p} ]; then
				vmove usr/share/geany-plugins/${p}
			fi
			if [ -x ${DESTDIR}/usr/share/doc/geany-plugins/${p} ]; then
				vmove usr/share/doc/geany-plugins/${p}
			fi
		done

		vmove usr/lib/geany-plugins/geanylua
	}
}
