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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
DPKG_EXPORT_BUILDFLAGS = 1

include /usr/share/dpkg/default.mk

define COMMON_CONFIGURE_ARGS
	--prefix=/usr
	--sysconfdir=/var/lib/aide/please-dont-call-aide-without-parameters
	--without-config-file --disable-default-db --with-zlib
	--with-xattr
	--with-posix-acl
	--with-e2fsattrs
	--disable-static
endef
EXTRA_CONFIGURE_ARGS= $(shell dpkg-buildflags --export=cmdline)

ifeq ($(DEB_HOST_ARCH_OS),linux)
EXTRA_CONFIGURE_ARGS+= --with-selinux --with-audit --with-capabilities
BUILT_USING_PACKAGES+= libselinux1-dev libaudit-dev libcap-dev
endif

BUILT_USING=$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W $(BUILT_USING_PACKAGES))

%:
		dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(strip ${COMMON_CONFIGURE_ARGS}) $(strip ${EXTRA_CONFIGURE_ARGS})

# make this execute_after_dh_auto_install after bookworm
override_dh_auto_install:
	dh_auto_install
	dh_installsystemd --name=dailyaidecheck
	dh_installsystemd --name=dailyaidecheck-buildcache
	# this is needed until dh compat 14
	dh_installsysusers
