--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 40739431FBC\r
+ for <notmuch@notmuchmail.org>; Tue, 8 Jul 2014 16:57:48 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 8mq5vpjXKcBG for <notmuch@notmuchmail.org>;\r
+ Tue, 8 Jul 2014 16:57:43 -0700 (PDT)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id D1A15431FD6\r
+ for <notmuch@notmuchmail.org>; Tue, 8 Jul 2014 16:57:31 -0700 (PDT)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1X4fGN-0005bH-Ev; Tue, 08 Jul 2014 20:57:31 -0300\r
+Received: (nullmailer pid 3527 invoked by uid 1000); Tue, 08 Jul 2014\r
+ 23:57:16 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v4 1/3] doc: build and install doxygen api docs\r
+Date: Tue, 8 Jul 2014 20:57:07 -0300\r
+Message-Id: <1404863829-3343-2-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.0.0.rc2\r
+In-Reply-To: <1404863829-3343-1-git-send-email-david@tethera.net>\r
+References: <1404657994-30628-4-git-send-email-david@tethera.net>\r
+ <1404863829-3343-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 08 Jul 2014 23:57:48 -0000\r
+\r
+In order to support out of tree builds, generate `doc/config.dox` from\r
+configure.\r
+\r
+In order to avoid hardcoding version in doxygen.cfg, generate\r
+doc/version.dox at build time.\r
+---\r
+ configure | 12 ++++++++++++\r
+ doc/Makefile.local | 27 +++++++++++++++++++++++++--\r
+ doc/doxygen.cfg | 5 ++---\r
+ 3 files changed, 39 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/configure b/configure\r
+index 9514d4d..fa44188 100755\r
+--- a/configure\r
++++ b/configure\r
+@@ -417,6 +417,15 @@ else\r
+ have_emacs=0\r
+ fi\r
+ \r
++printf "Checking if doxygen is available... "\r
++if doxygen -v > /dev/null 2>&1; then\r
++ printf "Yes.\n"\r
++ have_doxygen=1\r
++else\r
++ printf "No (so will not install api docs)\n"\r
++ have_doxygen=0\r
++fi\r
++\r
+ printf "Checking if sphinx is available and supports nroff output... "\r
+ if hash sphinx-build > /dev/null 2>&1 && python -m sphinx.writers.manpage > /dev/null 2>&1 ; then\r
+ printf "Yes.\n"\r
+@@ -829,6 +838,9 @@ HAVE_SPHINX=${have_sphinx}\r
+ # Whether there's a rst2man binary available for building documentation\r
+ HAVE_RST2MAN=${have_rst2man}\r
+ \r
++# Whether there's a doxygen binary available for building api documentation\r
++HAVE_DOXYGEN=${have_doxygen}\r
++\r
+ # The directory to which desktop files should be installed\r
+ desktop_dir = \$(prefix)/share/applications\r
+ \r
+diff --git a/doc/Makefile.local b/doc/Makefile.local\r
+index bbd4610..72b8f68 100644\r
+--- a/doc/Makefile.local\r
++++ b/doc/Makefile.local\r
+@@ -12,10 +12,12 @@ mkdocdeps := python $(srcdir)/$(dir)/mkdocdeps.py\r
+ \r
+ # Internal variables.\r
+ ALLSPHINXOPTS := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(srcdir)/$(dir)\r
++APIMAN := $(DOCBUILDDIR)/man/man3/notmuch.3\r
++DOXYFILE := $(srcdir)/$(dir)/doxygen.cfg\r
+ \r
+ .PHONY: sphinx-html sphinx-texinfo sphinx-info\r
+ \r
+-.PHONY: install-man build-man\r
++.PHONY: install-man build-man apidocs install-apidocs\r
+ \r
+ %.gz: %\r
+ rm -f $@ && gzip --stdout $^ > $@\r
+@@ -56,6 +58,23 @@ else\r
+ endif\r
+ touch ${MAN_ROFF_FILES} $@\r
+ \r
++install-man: install-apidocs\r
++\r
++ifeq ($(HAVE_DOXYGEN),1)\r
++MAN_GZIP_FILES += ${APIMAN}.gz\r
++apidocs: $(APIMAN)\r
++install-apidocs: apidocs\r
++ mkdir -p "$(DESTDIR)$(mandir)/man3"\r
++ install -m0644 $(DOCBUILDDIR)/man/man3/*.3.gz $(DESTDIR)/$(mandir)/man3\r
++\r
++$(APIMAN): $(dir)/config.dox $(srcdir)/$(dir)/doxygen.cfg $(srcdir)/lib/notmuch.h\r
++ mkdir -p $(DOCBUILDDIR)/man/man3\r
++ doxygen $(DOXYFILE)\r
++else\r
++apidocs:\r
++install-apidocs:\r
++endif\r
++\r
+ # Do not try to build or install man pages if a man page converter is\r
+ # not available.\r
+ ifeq ($(HAVE_SPHINX)$(HAVE_RST2MAN),00)\r
+@@ -74,8 +93,12 @@ install-man: ${MAN_GZIP_FILES}\r
+ cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz\r
+ endif\r
+ \r
++$(dir)/config.dox: version.stamp\r
++ echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@\r
++ echo "INPUT=${srcdir}/lib/notmuch.h" >> $@\r
++\r
+ $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py\r
+ $(mkdocdeps) $(srcdir)/doc $(DOCBUILDDIR) $@\r
+ \r
+ CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk $(DOCBUILDDIR)/.roff.stamp\r
+-CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES) $(dir)/conf.pyc\r
++CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES) $(dir)/conf.pyc $(dir)/config.dox\r
+diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg\r
+index bfbfcab..1a53af5 100644\r
+--- a/doc/doxygen.cfg\r
++++ b/doc/doxygen.cfg\r
+@@ -4,11 +4,11 @@\r
+ # Project related configuration options\r
+ #---------------------------------------------------------------------------\r
+ DOXYFILE_ENCODING = UTF-8\r
+-PROJECT_NAME = "Notmuch 0.18"\r
++@INCLUDE = "doc/config.dox"\r
+ PROJECT_NUMBER =\r
+ PROJECT_BRIEF =\r
+ PROJECT_LOGO =\r
+-OUTPUT_DIRECTORY =\r
++OUTPUT_DIRECTORY = doc/_build\r
+ CREATE_SUBDIRS = NO\r
+ OUTPUT_LANGUAGE = English\r
+ BRIEF_MEMBER_DESC = YES\r
+@@ -96,7 +96,6 @@ WARN_LOGFILE =\r
+ #---------------------------------------------------------------------------\r
+ # configuration options related to the input files\r
+ #---------------------------------------------------------------------------\r
+-INPUT = lib/notmuch.h\r
+ INPUT_ENCODING = UTF-8\r
+ FILE_PATTERNS =\r
+ RECURSIVE = NO\r
+-- \r
+2.0.0.rc2\r
+\r