#!/usr/bin/make -f

DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

BUILDDIR = $(CURDIR)/debian/build
DESTDIR = $(CURDIR)/debian/tmp

%:
	dh $@ --builddir $(BUILDDIR)

# Run configure.
#
# We want to be explicit about the user the daemon will run as, even
# though it matches the default, in case upstream changes their mind
# about the name at some point in the future.
override_dh_auto_configure:
	dh_auto_configure -- \
	                  -Dinit_script=other \
	                  -Dsystem_user=libvirtdbus

# Install files.
#
# We use debian/tmp as a staging area so that we can have full control
# over what exactly ends up in the package.
override_dh_auto_install:
	dh_auto_install --destdir $(DESTDIR)

# Install extra files.
#
# The upstream build system takes care of most files, but we also add
# a few extra taken from both upstream and downstream: this will make
# it possible to conveniently pick them up using the usual debhelper
# tools later.
execute_after_dh_auto_install:
	install -m 0755 -d \
	        $(DESTDIR)/usr/share/doc/libvirt-dbus/
	install -m 0644 \
	        NEWS.rst \
	        $(DESTDIR)/usr/share/doc/libvirt-dbus/NEWS
	install -m 0755 -d \
	        $(DESTDIR)/var/lib/polkit-1/localauthority/10-vendor.d/
	install -m 0644 \
	        debian/polkit/libvirt-dbus.pkla \
	        $(DESTDIR)/var/lib/polkit-1/localauthority/10-vendor.d/
