#!/usr/bin/make -f

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# We don't need - or can't, rather, enforce (cf. Policy 10.2)
# because libtool does some chrpath's and re-linking throughout
# the build process, and these options fail the build before
# lib tool gets it's chance to do anything.
# export DEB_LDFLAGS_MAINT_APPEND=-Wl,-z,defs

# main packaging script based on dh7 syntax
%:
	dh $@ --with python3

override_dh_autoreconf:
	dh_autoreconf ./autogen.sh

override_dh_auto_configure:
	./configure  --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --with-rundir=/run \
		--enable-dependency-tracking --disable-fatal-warnings

override_dh_auto_install:
	dh_auto_install
	find \( -name "*.a" -o -name "*.la" \) -delete
	mv $(CURDIR)/debian/tmp/usr/sbin/cibsecret $(CURDIR)/debian/tmp/usr/lib/heartbeat/

DEB_HOST_ARCH_OS=$(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
ifeq (linux,$(DEB_HOST_ARCH_OS))
override_dh_missing:
	dh_missing --fail-missing
endif

override_dh_install:
# we should probably use dh_install -X here, but it doesn't work
ifeq (hurd,$(DEB_HOST_ARCH_OS))
	sed -i -e'/bladehpi/d' -e '/ipmilan/d' -e '/systemd/d' debian/*.install
endif
ifeq (kfreebsd,$(DEB_HOST_ARCH_OS))
	sed -i -e '/systemd/d' debian/*.install
endif
	dh_install

override_dh_installinit:
	dh_installinit --name=logd -pcluster-glue --no-start --no-enable

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog

override_dh_python3:
	dh_python3 --no-ext-rename --shebang=/usr/bin/python3 /usr/lib/stonith/plugins
