#!/usr/bin/make -f

include /usr/share/dpkg/buildflags.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --builddirectory=debian/build

override_dh_auto_configure:
	dh_auto_configure -- \
		--with-mailpath=/var/mail	\
						\
		--enable-compressed		\
		--enable-debug			\
		--enable-fcntl			\
		--enable-hcache			\
		--enable-gpgme			\
		--enable-imap			\
		--enable-smtp			\
		--enable-pop			\
		--enable-sidebar		\
		--enable-nntp			\
		--enable-dotlock		\
		--disable-fmemopen		\
						\
		--with-curses			\
		--with-gnutls			\
		--with-gss			\
		--with-idn			\
		--with-mixmaster		\
		--with-sasl			\
						\
		--without-gdbm 			\
		--without-bdb			\
		--without-qdbm			\
		--with-tokyocabinet

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp
	
override_dh_install:
	cd debian/tmp/usr/share/doc/mutt && \
	rm -rf samples/iconv samples/ca-bundle.crt && \
	cp $(CURDIR)/UPDATING NEWS
	
	chmod +x debian/extra/lib/*
	
	( sed -e '/## More settings/,$$d' debian/tmp/etc/Muttrc || exit 1 ; \
	  cat debian/extra/rc/Muttrc.foot ) > debian/tmp/Muttrc
	
	dh_install

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog

override_dh_fixperms:
	dh_fixperms --exclude usr/bin/mutt_dotlock