#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

###
# header cache backend
# HCACHE_DB := bdb
# HCACHE_DB := gdbm
# HCACHE_DB := qdbm
HCACHE_DB := tokyocabinet
###

# Configure arguments

ifeq ($(HCACHE_DB),bdb)
    hcache_db := --without-gdbm --without-qdbm --without-tokyocabinet
endif
ifeq ($(HCACHE_DB),gdbm)
    hcache_db := --without-qdbm --without-bdb --without-tokyocabinet
endif
ifeq ($(HCACHE_DB),qdbm)
    hcache_db := --without-gdbm --without-bdb --without-tokyocabinet
endif
ifeq ($(HCACHE_DB),tokyocabinet)
    hcache_db := --without-gdbm --without-bdb --without-qdbm
    ifeq ($(shell dpkg --print-architecture),hurd-i386)
	hcache_db := --without-bdb --without-qdbm
    endif
endif

confflags =	--prefix=/usr			\
		--sysconfdir=/etc		\
		--mandir=/usr/share/man		\
		--with-docdir=/usr/share/doc	\
		--with-mailpath=/var/mail	\
						\
		--disable-dependency-tracking	\
						\
		--enable-compressed		\
		--enable-debug			\
		--enable-fcntl			\
		--enable-hcache			\
		--enable-gpgme			\
		--enable-imap			\
		--enable-smtp			\
		--enable-pop			\
						\
		--with-curses			\
		--with-gnutls			\
		--with-gss			\
		--with-idn			\
		--with-mixmaster		\
		--with-sasl			\
						\
		--enable-notmuch		\
						\
		$(hcache_db)


%:
	dh $@ --with quilt --with autoreconf --builddirectory=debian/build

override_dh_autoreconf:
	dh_autoreconf -Xmkinstalldirs

override_dh_auto_configure:
	dh_auto_configure -- $(confflags)

override_dh_strip:
	dh_strip --dbg-package=mutt-kz-dbg

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

override_dh_install:
	dh_install
	mv debian/mutt-kz/usr/bin/mutt debian/mutt-kz/usr/bin/mutt-kz

override_dh_installman:
	dh_installman
	mv debian/mutt-kz/usr/share/man/man1/mutt.1 debian/mutt-kz/usr/share/man/man1/mutt-kz.1
	mv debian/mutt-kz/usr/share/man/man5/muttrc.5 debian/mutt-kz/usr/share/man/man5/muttrc-kz.5

override_dh_builddeb:
	dh_builddeb -- -Zxz
