#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

FILES_MODIFIED_BY_BUILD = \
	doc/mpop.info \
	doc/stamp-vti \
	doc/version.texi \
	Makefile.in \
	aclocal.m4 \
	build-aux/compile \
	build-aux/depcomp \
	build-aux/install-sh \
	build-aux/mdate-sh \
	build-aux/missing \
	configure \
	doc/Makefile.in \
	scripts/Makefile.in \
	src/Makefile.in \
	config.h.in \
	po/Makefile.in.in

override_dh_autoreconf:
	# Backup files modified by autoreconf
	for file in $(FILES_MODIFIED_BY_BUILD); do \
		if [ -e $$file ] && [ ! -e $$file.keep ] ; then \
			cp $$file $$file.keep ; \
		fi \
	done
	# Tiny fixes in modified files by build (use gettext 0.20)
	sed -i -r 's/(AC_SUBST\(\[GETTEXT_MACRO_VERSION\], \[)0.19(\]\))/\10.20\2/' aclocal.m4
	sed -i -r 's/^(GETTEXT_MACRO_VERSION =).*$$/\1 0.20/' po/Makefile.in.in
	dh_autoreconf

override_dh_auto_configure:
	dh_auto_configure -- --with-libsecret --with-libgsasl --with-libidn --with-ssl=gnutls

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp

override_dh_clean:
	dh_clean
	# Restore files modified by autoreconf
	for file in $(FILES_MODIFIED_BY_BUILD); do \
		if [ -e $$file.keep ] ; then \
			rm -f $$file ; \
			mv $$file.keep $$file ; \
		fi \
	done

%:
	dh $@
