# Template file for 'hexchat'
pkgname=hexchat
version=2.14.3
revision=3
build_style=meson
configure_args="-Dwith-dbus=true -Dwith-ssl=true -Dwith-text=false
 -Dwith-perl=/usr/bin/perl -Dwith-python=python3
 -Dwith-lua=$(vopt_if LuaJIT luajit lua)"
hostmakedepends="gettext pkg-config glib-devel"
makedepends="gtk+-devel libressl-devel dbus-glib-devel perl libnotify-devel
 libcanberra-devel libxml2-devel pciutils-devel libproxy-devel
 iso-codes python3-devel $(vopt_if LuaJIT LuaJIT-devel lua53-devel)"
depends="desktop-file-utils enchant"
short_desc="GTK+ based IRC client successor of Xchat"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://hexchat.github.io/"
changelog="https://hexchat.readthedocs.org/en/latest/changelog.html"
distfiles="https://dl.hexchat.net/hexchat/${pkgname}-${version}.tar.xz"
checksum=901a9d13db5a4da69b827f6093306bbd16863dc49016f7668bd3e4506512e882
build_options="LuaJIT"
lib32disabled=yes

case "$XBPS_TARGET_MACHINE" in
	arm*-musl) : "LuaJIT is broken for musl cross arches" ;;
	*) build_options_default+=" LuaJIT" ;;
esac

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" dbus-glib-devel libxml2-devel gdk-pixbuf perl
	 shared-mime-info"
fi

# Liberation
pre_build() {
	# Remove nonfree browser references
	sed -i '\|NAME Open Link| s|a new Firefox Window|Browser|' src/common/hexchat.c
	sed -i '\|NAME Open Link| s|firefox -new-window %s\\n\\n";|xdg-open %s\\n\\n";|' src/common/hexchat.c
}

post_install() {
	# Remove useless files.
	rm -rf ${DESTDIR}/usr/include
	rm -rf ${DESTDIR}/usr/lib/pkgconfig
}

hexchat-perl_package() {
	lib32disabled=yes
	short_desc+=" - perl plugin"
	depends="${sourcepkg}-${version}_${revision}"
	pkg_install() {
		vmove usr/lib/hexchat/plugins/perl.so
	}
}

hexchat-python3_package() {
	lib32disabled=yes
	short_desc+=" - Python3 plugin"
	depends="${sourcepkg}-${version}_${revision}"
	pkg_install() {
		vmove usr/lib/hexchat/plugins/python.so
	}
}

hexchat-lua_package() {
	lib32disabled=yes
	short_desc+=" - lua plugin"
	depends="${sourcepkg}-${version}_${revision}"
	pkg_install() {
		vmove usr/lib/hexchat/plugins/lua.so
	}
}
