--- /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 6BF4E431FBD\r
+ for <notmuch@notmuchmail.org>; Sun, 6 Jul 2014 10:54:01 -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 Cr7pqOv-4tQm for <notmuch@notmuchmail.org>;\r
+ Sun, 6 Jul 2014 10:53:55 -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 3CEFE431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 6 Jul 2014 10:53:46 -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 1X3qd8-0001Hd-Ep; Sun, 06 Jul 2014 14:53:38 -0300\r
+Received: (nullmailer pid 30894 invoked by uid 1000); Sun, 06 Jul 2014\r
+ 14:46:38 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v3 1/3] doc: build and install doxygen api docs\r
+Date: Sun, 6 Jul 2014 11:46:32 -0300\r
+Message-Id: <1404657994-30628-2-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.0.0.rc2\r
+In-Reply-To: <1404657994-30628-1-git-send-email-david@tethera.net>\r
+References: <1404657994-30628-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: Sun, 06 Jul 2014 17:54:01 -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 | 18 ++++++++++++++++++\r
+ doc/Makefile.local | 26 ++++++++++++++++++++++++--\r
+ doc/doxygen.cfg | 6 +++---\r
+ 3 files changed, 45 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/configure b/configure\r
+index 9514d4d..ec3a895 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
+@@ -725,6 +734,12 @@ commands to compile and install notmuch:\r
+ \r
+ EOF\r
+ \r
++# construct the Doxygen file list\r
++cat > doc/config.dox <<EOF\r
++# This doxgen config snippet generated by ../configure\r
++INPUT=${srcdir}/lib/notmuch.h\r
++EOF\r
++\r
+ # construct the Makefile.config\r
+ cat > Makefile.config <<EOF\r
+ # This Makefile.config was automatically generated by the ./configure\r
+@@ -829,6 +844,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..618b840 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)/version.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,11 @@ install-man: ${MAN_GZIP_FILES}\r
+ cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz\r
+ endif\r
+ \r
++$(dir)/version.dox: version.stamp\r
++ echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@\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)/version.dox $(dir)/config.dox\r
+diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg\r
+index bfbfcab..68e8969 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/version.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,7 @@ WARN_LOGFILE =\r
+ #---------------------------------------------------------------------------\r
+ # configuration options related to the input files\r
+ #---------------------------------------------------------------------------\r
+-INPUT = lib/notmuch.h\r
++@INCLUDE = doc/config.dox\r
+ INPUT_ENCODING = UTF-8\r
+ FILE_PATTERNS =\r
+ RECURSIVE = NO\r
+-- \r
+2.0.0.rc2\r
+\r