# Template file for 'polkit-elogind'
pkgname=polkit-elogind
version=0.115
revision=3
wrksrc="polkit-${version}"
build_style=gnu-configure
configure_args="$(vopt_enable gir introspection) --disable-static
 --with-authfw=pam --with-os-type=void --with-mozjs=mozjs-52.0"
make_dirs="
 /etc/polkit-1/rules.d 0700 polkitd polkitd
 /usr/share/polkit-1/rules.d 0700 polkitd polkitd"
hostmakedepends="automake libtool gettext-devel git glib-devel
 gobject-introspection gtk-doc intltool pkg-config"
makedepends="elogind-devel libglib-devel mozjs52-devel pam-devel"
short_desc="Authorization Toolkit"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://www.freedesktop.org/wiki/Software/polkit"
distfiles="${FREEDESKTOP_SITE}/polkit/releases/polkit-${version}.tar.gz"
checksum=2f87ecdabfbd415c6306673ceadc59846f059b18ef2fce42bac63fe283f12131
system_accounts="polkitd"
provides="polkit-${version}_${revision}"
replaces="polkit>=0"

# Package build options
build_options="gir"
# Disable gir for cross builds.
if [ -z "$CROSS_BUILD" ]; then
	build_options_default+=" gir"
fi

pre_configure() {
	autoreconf -fi
	# Drop requirement of /sys/fs/cgroup/systemd test in configure... WTF.
	sed -e 's,/sys/fs/cgroup/systemd/,/sys/fs/cgroup,g' -i configure
}

post_configure() {
	if [ "$CROSS_BUILD" ]; then
		sed -e "s#-include \(/usr/include/mozjs-52/js/RequiredDefines\.h\)#-include ${XBPS_CROSS_BASE}\1#" \
			-i $(find -name Makefile)
	fi
}

post_install() {
	vinstall ${FILESDIR}/polkit-1.pam 644 etc/pam.d polkit-1

	rm -r $DESTDIR/usr/include
	rm -r $DESTDIR/usr/lib/pkgconfig
	if [ "$build_option_gir" ]; then
		rm -r $DESTDIR/usr/share/gir-*
	fi
	rm -r $DESTDIR/usr/lib/*.so
}
