#!/usr/bin/make -f

# Add hardening build flags.  We have to omit PIE because it breaks the Perl
# module build (and probably the other interpretors as well).
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow,+pie

# Append the settings for the password file path and password change host
# used at Stanford to the CFLAGS.
export DEB_CFLAGS_MAINT_APPEND = -DHOST='"password-change.stanford.edu"' \
	-DPASSWD_FILE='"/afs/ir.stanford.edu/service/etc/passwd.all"'

# Link with --as-needed so that the remctl client library doesn't inherit
# the shared library dependencies of libremctl.
#
# FIXME: Uncomment when we no longer care about squeeze backports, and add
# --as-needed to the dh_autoreconf invocation.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Path to the Heimdal variant of the kadmin-remctl package.
HEIMDAL = debian/kadmin-remctl-heimdal

%:
	dh $@ --parallel --with autoreconf

override_dh_autoreconf:
	dh_autoreconf

override_dh_auto_configure:
	dh_auto_configure --parallel -- --enable-reduced-depends

override_dh_auto_install:
	dh_auto_install
	install -d debian/kadmin-remctl/etc/remctl/reset
	install -m 644 remctl/password \
	    debian/kadmin-remctl/etc/remctl/reset/remctl.conf

override_dh_install:
	dh_install
	mv $(HEIMDAL)/usr/sbin/kadmin-backend-heim \
	    $(HEIMDAL)/usr/sbin/kadmin-backend
	mv $(HEIMDAL)/usr/share/man/man8/kadmin-backend-heim.8 \
	    $(HEIMDAL)/usr/share/man/man8/kadmin-backend.8
	perl -i -pe 's/KADMIN-BACKEND-HEIM/KADMIN-BACKEND/g' \
	    $(HEIMDAL)/usr/share/man/man8/kadmin-backend.8

override_dh_installchangelogs:
	dh_installchangelogs NEWS
