#!/usr/bin/make -f

# Enable full hardening and reproducible-build flags.
# reproducible=+all makes dpkg-buildflags inject -ffile-prefix-map so the package
# build path does not leak into the binaries; combined with debhelper deriving
# SOURCE_DATE_EPOCH from the changelog date and Debian's deterministic binutils,
# this yields a bit-for-bit reproducible package.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all reproducible=+all

# Tell debhelper to use the CMake build system
%:
	dh $@ --buildsystem=cmake

# Disable autoreconf since we are using CMake exclusively
override_dh_autoreconf:
	@echo "Skipping autoreconf (using CMake instead)"

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_REDIS=ON \
		-DWITH_CURL=ON \
		-DINSTALL_SYSTEMD_UNIT=OFF

# Ship the bundled sample as the live, verify-only default configuration.
# It is not produced by the CMake build, so install it from debian/ into the
# phoenixdkim package; dh_installdeb registers files under /etc as conffiles.
execute_after_dh_install:
	install -D -m 0644 debian/phoenixdkim.conf.sample \
		debian/phoenixdkim/etc/phoenixdkim/phoenixdkim.conf

# Test results on kfreebsd-* are inconsistent, but not due to package bugs.
override_dh_auto_test:
	dh_auto_test

override_dh_installsystemd:
	dh_installsystemd --name=phoenixdkim

override_dh_installchangelogs:
	dh_installchangelogs RELEASE_NOTES
