# Template file for 'libportal'
pkgname=libportal
version=0.7.1
revision=1
build_style=meson
build_helper="gir"
configure_args="$(vopt_bool gtk_doc docs) $(vopt_bool gir vapi)
 -Dbackend-gtk3=enabled -Dbackend-gtk4=enabled -Dbackend-qt5=enabled"
hostmakedepends="pkg-config glib-devel gobject-introspection $(vopt_if gir vala)
 $(vopt_if gtk_doc gi-docgen) qt5-host-tools"
makedepends="glib-devel gobject-introspection gtk+3-devel gtk4-devel
 qt5-tools-devel qt5-x11extras-devel"
checkdepends="python3-dbusmock python3-pytest xvfb-run"
short_desc="Flatpak portal library"
maintainer="Orphaned <orphan@voidlinux.org>"
license="LGPL-2.0-or-later"
homepage="https://github.com/flatpak/libportal"
distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
checksum=297b90b263fad22190a26b8c7e8ea938fe6b18fb936265e588927179920d3805
make_check_pre="xvfb-run"

build_options="gir gtk_doc"
build_options_default="gir gtk_doc"

libportal-devel_package() {
	depends="libportal>=${version}_${revision} glib-devel"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include/libportal
		vmove "usr/lib/libportal.so"
		vmove usr/lib/pkgconfig/libportal.pc
		if [ "$build_option_gtk_doc" ]; then
			vmove usr/share/doc
		fi
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0/Xdp-1.0.gir
			vmove "usr/share/vala/vapi/libportal.*"
		fi
	}
}

libportal-gtk3_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - GTK3"
	pkg_install() {
		vmove "usr/lib/libportal-gtk3.so.*"
		if [ "$build_option_gir" ]; then
			vmove "usr/lib/girepository-1.0/XdpGtk3*"
		fi
	}
}

libportal-gtk3-devel_package() {
	depends="libportal-gtk3>=${version}_${revision} libportal-devel>=${version}_${revision} glib-devel gtk+3-devel"
	short_desc+=" - GTK3 - development files"
	pkg_install() {
		vmove usr/include/libportal-gtk3
		vmove "usr/lib/libportal-gtk3.so"
		vmove usr/lib/pkgconfig/libportal-gtk3.pc
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0/XdpGtk3*
			vmove "usr/share/vala/vapi/libportal-gtk3*"
		fi
	}
}

libportal-gtk4_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - GTK4"
	pkg_install() {
		vmove "usr/lib/libportal-gtk4.so.*"
		if [ "$build_option_gir" ]; then
			vmove "usr/lib/girepository-1.0/XdpGtk4*"
		fi
	}
}

libportal-gtk4-devel_package() {
	depends="libportal-gtk4>=${version}_${revision} libportal-devel>=${version}_${revision} glib-devel gtk4-devel"
	short_desc+=" - GTK4 - development files"
	pkg_install() {
		vmove usr/include/libportal-gtk4
		vmove "usr/lib/libportal-gtk4.so"
		vmove usr/lib/pkgconfig/libportal-gtk4.pc
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0/XdpGtk4*
			vmove "usr/share/vala/vapi/libportal-gtk4*"
		fi
	}
}

libportal-qt5_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - Qt5"
	pkg_install() {
		vmove "usr/lib/libportal-qt5.so.*"
	}
}

libportal-qt5-devel_package() {
	depends="libportal-devel>=${version}_${revision}
	 libportal-qt5>=${version}_${revision} qt5-devel
	 qt5-x11extras-devel"
	short_desc+=" - Qt5 - development files"
	pkg_install() {
		vmove usr/include/libportal-qt5
		vmove "usr/lib/libportal-qt5.so"
		vmove usr/lib/pkgconfig/libportal-qt5.pc
	}
}
