#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export WANT_DRBD_REPRODUCIBLE_BUILD=1

%:
	dh $@ --with bash-completion

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/drbd-utils.drbd.init

override_dh_auto_configure:
	dh_auto_configure -- \
		--with-udev \
		--with-xen \
		--with-pacemaker \
		--with-rgmanager \
		--with-bashcompletion \
		--with-initscripttype=both \
		--with-bashcompletion=no

override_dh_auto_install:
	dh_auto_install --destdir debian/drbd-utils

override_dh_install:
	dh_install

	# Place the initscript where dh_installinit can find it
	mv $(CURDIR)/debian/drbd-utils/etc/init.d/drbd $(CURDIR)/debian/drbd-utils.drbd.init

	# Remove /run/drbd, as it shouldn't be shipped in the package
	rmdir $(CURDIR)/debian/drbd-utils/var/run/drbd
	rmdir $(CURDIR)/debian/drbd-utils/var/run

	# systemd/kmod integration
	install -D -m0644 $(CURDIR)/debian/drbd.modules-load.d $(CURDIR)/debian/drbd-utils/usr/lib/modules-load.d/drbd.conf

override_dh_installinit:
	dh_installinit --name=drbd --no-enable --no-start --no-stop-on-upgrade

override_dh_installsystemd:
	dh_installsystemd --name=drbd --no-enable --no-start --no-stop-on-upgrade

override_dh_installman:
	dh_installman --language=all

.PHONY: override_dh_auto_configure override_dh_install \
	override_dh_auto_clean override_dh_installinit \
	override_dh_auto_install override_dh_installsystemd \
	override_dh_installman override_dh_missing
