#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

export DESTDIR=$(shell pwd)/debian/tmp
BUILD_DIR = debian/build

%:
	dh $@ --with autoreconf,autotools-dev,python2,systemd

override_dh_auto_configure:
	dh_auto_configure -- --prefix=/usr \
		--includedir=/usr/include \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--with-initddir=/etc/init.d \
		--enable-systemd \
		--with-linux-backend-modules="xen-evtchn xen-gntdev xen-gntalloc xen-blkback xen-privcmd xen-netback" \
		--with-systemd=/lib/systemd/system \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--disable-ocamltools \
		--disable-blktap2

override_dh_auto_build:
	dh_clean --keep
	make dist-tools

override_dh_auto_install:
	make DESTDIR=$(DESTDIR) install-tools
	(cd debian/tmp; rm -r `grep ^[a-z] ../not-installed`)
	dh_testdir
	dh_testroot
	dh_install --arch --sourcedir=debian/tmp --fail-missing
	dh_strip --arch
	dh_makeshlibs -V
	dh_shlibdeps
	dh_installchangelogs -XChangelog
	#dh_installdirs
	#dh_installdocs
	#dh_installexamples
	#dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol -- $(GENCONTROL_ARGS)
	#dh_gencontrol
	dh_md5sums
	dh_builddeb
