#!/usr/bin/make -f

# https://pkg-perl.alioth.debian.org/debhelper.html#Occasionally_Useful
PACKAGE = $(shell dh_listpackages)
TMP     = $(CURDIR)/debian/$(PACKAGE)

# https://wiki.debian.org/HardeningWalkthrough
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Needed to pass the dh-generated buildflags to the configure script
export EXTRA_CFLAGS=$(CFLAGS) $(CPPFLAGS)
export EXTRA_LDFLAGS=$(LDFLAGS)

%:
	dh $@

override_dh_auto_configure:
	$(MAKE) config \
		VERBOSE=1 \
		VAL_PREFIX=/usr \
		VAL_LIBEXECDIR=/usr/lib/s-nail \
		VAL_SYSCONFDIR=/etc \
		VAL_MTA=/usr/sbin/sendmail \
		VAL_MAIL=/var/mail

override_dh_fixperms:
	dh_fixperms

	# This could be avoided with VAL_PRIVSEP_GROUP=mail, but this
	# setting has been deprecated upstream.
	chgrp mail $(TMP)/usr/lib/s-nail/s-nail-dotlock

override_dh_auto_test:
	HOME=/tmp dh_auto_test

override_dh_installchangelogs:
	dh_installchangelogs NEWS
