#!/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:
	./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
		--sbindir=/sbin --with-udev --with-xen \
		--with-pacemaker --with-rgmanager --with-bashcompletion \
		--with-initscripttype=sysv \
		--with-bashcompletion=no

override_dh_auto_build:
	dh_auto_build
	$(MAKE) doc

override_dh_auto_install:
	dh_auto_install --destdir debian/drbd-utils
	# Shipped with dh_installman, upstream creates a dangling symlink
	rm debian/drbd-utils/usr/share/man/man8/drbd-overview.8
	rm debian/drbd-utils/usr/share/man/ja/man8/drbd-overview.8

override_dh_install:
	dh_install --fail-missing

	# Move drbd-overview to /usr/sbin
	mv $(CURDIR)/debian/drbd-utils/sbin/drbd-overview $(CURDIR)/debian/drbd-utils/usr/sbin/

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

	# systemd/kmod integration
	install -D -m0644 $(CURDIR)/debian/drbd.modules-load.d $(CURDIR)/debian/drbd-utils/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 documentation/v9/drbd-overview.8
	dh_installman --language=ja documentation/ja/v9/drbd-overview.8

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