-export LC_ALL=C
-include debian/scripts/vars
-
-BUILD_DIR := $(SOURCE_DIR)/$(TAR_DIR)
-B := $(BUILD_DIR)
-D := $(CURDIR)/debian/mutt
-
-# Comment this line if you want the header cache with gdbm
-HCACHE_WITH_DB := --without-gdbm
-
-clean:
- $(MAKE) -f debian/sys-build.mk source.clean
- dh_clean
-
-# target used by the maintainer
-unpack.nopatch:
- $(MAKE) -f debian/sys-build.mk source.build
- rm -f $B/Muttrc $B/doc/muttrc.man \
- $B/doc/manual.sgml $B/doc/manual.txt $B/doc/*.html
-
-diff:
- $(MAKE) -f debian/sys-build.mk make-diff
-
-unpack: $(STAMP_DIR)/source.make
-$(STAMP_DIR)/source.make:
- $(MAKE) -f debian/sys-build.mk source.make
+include /usr/share/quilt/quilt.make
+
+###
+# header cache backend
+# HCACHE_DB := bdb
+HCACHE_DB := gdbm
+# HCACHE_DB := qdbm
+###
+# GPGME backend
+# GPGME := --enable-gpgme
+###
+
+# Configure arguments
+
+ifeq ($(HCACHE_DB),bdb)
+ hcache_db := --without-gdbm --without-qdbm
+endif
+ifeq ($(HCACHE_DB),gdbm)
+ hcache_db := --without-qdbm --without-bdb
+endif
+ifeq ($(HCACHE_DB),qdbm)
+ hcache_db := --without-gdbm --without-bdb
+endif
+
+confflags = --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --with-sharedir=/usr/share/mutt \
+ --with-docdir=/usr/share/doc \
+ --with-mailpath=/var/mail \
+ \
+ --disable-dependency-tracking \
+ \
+ --enable-compressed \
+ --enable-debug \
+ --enable-fcntl \
+ --enable-hcache \
+ $(GPGME) \
+ --enable-imap \
+ --enable-smtp \
+ --enable-inodesort \
+ --enable-pop \
+ \
+ --with-curses \
+ --with-gnutls \
+ --with-idn \
+ --with-mixmaster \
+ --with-sasl \
+ \
+ $(hcache_db)
+
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+confflags += --build $(DEB_BUILD_GNU_TYPE)
+# Only specify --host when cross-compiling
+ifneq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+ confflags += --host $(DEB_HOST_GNU_TYPE)
+endif
+
+# CFLAGS
+CFLAGS = -Wall -g
+CPPFLAGS = -I/usr/include/qdbm
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+# Directory to make the build on
+objdir = $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)
+
+configure: $(objdir)/configure-stamp
+$(objdir)/configure-stamp: $(QUILT_STAMPFN)
+ dh_testdir
+
+ autoreconf --install --include=m4
+ -mkdir $(objdir)
+ cd $(objdir) && \
+ env CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
+ ../configure $(confflags)
+
+ echo '#include "config-debian.h"' >>$(objdir)/config.h