#!/usr/bin/make -f
-SHELL+= -e
-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
+include /usr/share/quilt/quilt.make
+
+###################### user serviceable parts ######################
+
+###
+# build a separate mutt-patched package?
+BUILD_PATCHED := yes
+###
+# header cache backend
+# HCACHE_DB := bdb
+HCACHE_DB := gdbm
+# HCACHE_DB := qdbm
+# HCACHE_DB := tokyocabinet
+###
+# GPGME backend
+GPGME := --enable-gpgme
+###
+
+###################### variables ######################
+
+ifneq ($(BUILD_PATCHED),yes)
+export DH_OPTIONS := -Nmutt-patched
+endif
+
+# 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
+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-gss \
+ --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)
+
+###################### main ######################
+
+$(objdir)-patched/build-stamp: $(QUILT_STAMPFN)
+ dh_testdir
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
+ -mkdir $(objdir)-patched
+
+ifeq ($(BUILD_PATCHED),yes)
+ ###################### building mutt-patched ######################
+ autoreconf --install --include=m4
+ cd $(objdir)-patched && \
+ env CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
+ ../configure $(confflags)
+
+ echo '#include "config-debian.h"' >> $(objdir)-patched/config.h
+
+ # we should just "make mutt" here, but that doesn't work yet
+ cd $(objdir)-patched && $(MAKE) CFLAGS="$(CFLAGS)"
+endif
- # sort the patches list
- sort $B/PATCHES > $B/PATCHES.temp
- mv $B/PATCHES.temp $B/PATCHES
-
- # rebuild these files
- rm -f $B/Muttrc $B/doc/muttrc.man \
- $B/doc/manual.sgml $B/doc/manual.txt $B/doc/*.html
-
- # we include some #defines in debian-config.h
- echo '#include "debian-config.h"' >> $B/config.h.in
-
- # do not rebuild these files
- touch $B/configure.in $B/aclocal.m4 $B/Makefile.in $B/configure \
- $B/stamp-h.in $B/config.h.in
- touch $@
-
- # update config.guess and config.sub
- -test -r /usr/share/misc/config.sub && \
- cp -f /usr/share/misc/config.sub $B/config.sub
- -test -r /usr/share/misc/config.guess && \
- cp -f /usr/share/misc/config.guess $B/config.guess
-
-configure: $(STAMP_DIR)/configure
-$(STAMP_DIR)/configure: $(STAMP_DIR)/source.make
- CC=cc ac_cv_path_ISPELL=ispell \
- SENDMAIL=/usr/sbin/sendmail PERL=/usr/bin/perl \
- $(MAKE) -f debian/sys-build.mk source.command SOURCE_CMD=" \
- ./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \
- --with-sharedir=/usr/share/mutt --with-docdir=/usr/share/doc \
- --with-mailpath=/var/mail \
- --enable-fcntl --enable-pop --enable-imap \
- --with-mixmaster --with-sasl2 --with-idn \
- --with-curses \
- --with-gnutls \
- --enable-debug \
- --enable-inodesort \
- --enable-compressed \
- --enable-hcache $(HCACHE_WITH_DB) \
- "
touch $@
-build: $(STAMP_DIR)/build
-$(STAMP_DIR)/build: $(STAMP_DIR)/configure $(STAMP_DIR)/source.make
- GROFF_NO_SGR=1 \
- $(MAKE) -f debian/sys-build.mk source.command SOURCE_CMD=" \
- make keymap_defs.h all CFLAGS=\"-O2 -g\" \
- "
+build build-arch: $(objdir)/build-stamp
+$(objdir)/build-stamp: $(objdir)-patched/build-stamp
+ ###################### building mutt ######################
+ QUILT_PATCHES=$(QUILT_PATCH_DIR) quilt --quiltrc /dev/null pop mutt.org
+
+ autoreconf --install --include=m4
+ -mkdir $(objdir)
+ cd $(objdir) && \
+ env CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
+ ../configure $(confflags)
+
+ echo '#include "config-debian.h"' >>$(objdir)/config.h
+
+ cd $(objdir) && $(MAKE) CFLAGS="$(CFLAGS)"
+
touch $@
-binary-arch: $(STAMP_DIR)/build checkroot
+install: build
+ ###################### install ######################
dh_testdir
- dh_clean -k
- $(MAKE) -f debian/sys-build.mk source.command SOURCE_CMD=" \
- $(MAKE) install DESTDIR=$D SUBDIRS=\"intl po\" \
- "
-
- dh_installdirs -p mutt usr/share/pixmaps usr/lib/mutt/ \
- usr/bin/ usr/share/doc/mutt/html/
+ dh_testroot
+ dh_prep
+ cd $(objdir) && $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
+
+ cd debian/tmp/usr/share/doc && \
+ rm -rf samples/iconv samples/ca-bundle.crt && \
+ mv NEWS NEWS.old && \
+ cp $(CURDIR)/UPDATING NEWS
+
+ chmod +x debian/extra/lib/*
+ chmod +x debian/header.awk
+ debian/header.awk debian/patches/features/* \
+ debian/patches/mutt-patched/* > debian/tmp/README.Patches
+
+ ( sed -e '/## More settings/,$$d' $(objdir)/doc/Muttrc || exit 1 ; \
+ cat debian/extra/rc/Muttrc.foot ) > debian/tmp/Muttrc
+
+ ( echo "# GnuPG configuration"; \
+ grep '^set' contrib/gpg.rc; \
+ echo ) > debian/tmp/gpg.rc
+
+ifeq ($(BUILD_PATCHED),yes)
+ # temporarily call the binary mutt-patched so dh_strip gets the debug file name right
+ install -D $(objdir)-patched/mutt debian/mutt-patched/usr/bin/mutt-patched
+endif
+
+ # reportbug driver
+ dh_installdirs
+ install -m644 debian/bug/control $(CURDIR)/debian/mutt/usr/share/bug/mutt
+ install debian/bug/script $(CURDIR)/debian/mutt/usr/share/bug/mutt
+
+binary binary-arch: install
+ ###################### binary ######################
+ dh_install
+ dh_installman
dh_installmenu
- dh_installdocs $B/README $B/README.SECURITY $B/README.SSL $B/NEWS \
- $B/doc/manual.txt $B/doc/PGP-Notes.txt extra/README.SMIME
- cp $B/doc/*.html $D/usr/share/doc/mutt/html/
- for file in README BUGS TODO; do \
- cp $B/imap/$$file $D/usr/share/doc/mutt/$$file.IMAP; \
- done
- # generate README.Patches
- for file in $(EXTRA_PATCHES)/*; do \
- mawk -f debian/gen-README.Patches $$file >> \
- $D/usr/share/doc/mutt/README.Patches; \
- done
- dh_installexamples \
- $B/contrib/*rc $B/contrib/sample.muttrc-tlr \
- extra/ray.muttrc extra/colors.angdraug
- dh_installman \
- $B/doc/mutt.1 $B/doc/dotlock.man \
- $B/doc/muttrc.man $B/doc/mbox.man
-
- install --mode=755 extra/debian-ldap-query extra/mailspell \
- extra/source-muttrc.d $D/usr/lib/mutt/
- cp extra/mutt.xpm $D/usr/share/pixmaps/
-
-# some fixes to the package structure
- mv $D/usr/bin/pgp* $D/usr/lib/mutt/
- mv $D/usr/share/man/man1/dotlock.1 $D/usr/share/man/man1/mutt_dotlock.1
- rm $D/etc/mime.types $D/usr/bin/muttbug $D/usr/bin/flea
-
-# I think the default config file with the embedded manual is too big
- mv $D/etc/Muttrc $D/usr/share/doc/mutt/examples/
- cp $B/Muttrc.head $D/etc/Muttrc
- echo "# GnuPG configuration" >> $D/etc/Muttrc
- grep ^set $B/contrib/gpg.rc \
- | sed -e 's#pgpewrap#/usr/lib/mutt/pgpewrap#' \
- | sed -e 's#/usr/bin/gpg#gpg#' \
- >> $D/etc/Muttrc
- cat extra/smime-paths.rc extra/source-Muttrc.d.rc >> $D/etc/Muttrc
-
- dh_installchangelogs $B/ChangeLog
- dh_strip
- dh_compress
- dh_fixperms --exclude=usr/bin/mutt_dotlock
+ dh_installmime
+ dh_installdocs
+ dh_installexamples
+ dh_installchangelogs ChangeLog
+ -dh_lintian
+
+ dh_strip --dbg-package=mutt-dbg
+ rm -rf $(CURDIR)/debian/mutt-dbg/usr/share/doc/mutt-dbg \
+ $(CURDIR)/debian/mutt-patched/usr/share/doc/mutt-patched
+ifeq ($(BUILD_PATCHED),yes)
+ mv debian/mutt-patched/usr/bin/mutt-patched debian/mutt-patched/usr/bin/mutt
+endif
+
+ dh_link
+ dh_compress --exclude usr/share/doc/mutt/README.Patches
+ dh_fixperms --exclude usr/bin/mutt_dotlock
dh_installdeb
dh_shlibdeps
dh_gencontrol
+ dh_md5sums
dh_builddeb
-binary: binary-arch
-
-extra-clean:
- find -type f \( -name "*.orig" -o -name "*.rej" \) -exec rm -v {} \;
+build-indep binary-indep:
+ @echo "Nothing to do."
-checkroot:
- test root = "`whoami`"
+clean: unpatch
+ ###################### clean ######################
+ dh_testdir
+ dh_testroot
+
+ # please dpkg-source
+ rm -f po/*.gmo
+ touch PATCHES
+
+ # remove build trees
+ rm -rf $(objdir) $(objdir)-patched
+
+ # remove autotool-generated files so they don't show up in the diff.gz
+ rm -f configure config.h.in
+ rm -f Makefile.in contrib/Makefile.in imap/Makefile.in doc/Makefile.in m4/Makefile.in
+
+ # clean PATCHES hunks (blame quilt refresh)
+ for p in `grep -rl PATCHES debian/patches` ; do perl -wi debian/fix-PATCHES.pl $$p ; done
+
+ dh_clean
-.PHONY: binary binary-arch build clean configure checkroot extra-clean
+.PHONY: configure build build-arch build-indep clean install binary binary-arch binary-indep patch