# Template file for 'libportal'
pkgname=libportal
version=0.6
revision=1
build_style=meson
configure_args="$(vopt_bool gtk_doc docs) $(vopt_bool gir vapi) -Dbackends=gtk3,gtk4"
hostmakedepends="pkg-config glib-devel gobject-introspection $(vopt_if gir vala)
 $(vopt_if gtk_doc gi-docgen)"
makedepends="glib-devel gobject-introspection gtk+3-devel gtk4-devel"
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=88a12c3ba71bc31acff7238c280de697d609cebc50830c3766776ec35abc6566

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

if [ -n "$CROSS_BUILD" ]; then
	hostmakedepends+=" qemu-user-static prelink-cross"
fi

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
	}
}
