--- /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 28497429E30\r
+ for <notmuch@notmuchmail.org>; Tue, 30 Dec 2014 12:30:43 -0800 (PST)\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 mDyxwgllZz7r for <notmuch@notmuchmail.org>;\r
+ Tue, 30 Dec 2014 12:30:42 -0800 (PST)\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 9042B431FD4\r
+ for <notmuch@notmuchmail.org>; Tue, 30 Dec 2014 12:30:41 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1Y63RB-00010C-7k; Tue, 30 Dec 2014 16:30:41 -0400\r
+Received: (nullmailer pid 10591 invoked by uid 1000); Tue, 30 Dec 2014\r
+ 20:29:44 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v2 1/5] build: integrate building ruby bindings into notmuch\r
+ build process\r
+Date: Tue, 30 Dec 2014 21:29:36 +0100\r
+Message-Id: <1419971380-10307-2-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.3\r
+In-Reply-To: <1419971380-10307-1-git-send-email-david@tethera.net>\r
+References: <1419971380-10307-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, 30 Dec 2014 20:30:43 -0000\r
+\r
+Because ruby generates a Makefile, we have to use recursive make.\r
+Because mkmf.rb hardcodes the name Makefile, put our Makefile{.local}\r
+in the parent directory.\r
+---\r
+ bindings/Makefile | 7 +++++++\r
+ bindings/Makefile.local | 18 ++++++++++++++++++\r
+ configure | 18 ++++++++++++++++++\r
+ 3 files changed, 43 insertions(+)\r
+ create mode 100644 bindings/Makefile\r
+ create mode 100644 bindings/Makefile.local\r
+\r
+diff --git a/bindings/Makefile b/bindings/Makefile\r
+new file mode 100644\r
+index 0000000..de492a7\r
+--- /dev/null\r
++++ b/bindings/Makefile\r
+@@ -0,0 +1,7 @@\r
++# See Makefile.local for the list of files to be compiled in this\r
++# directory.\r
++all:\r
++ $(MAKE) -C .. all\r
++\r
++.DEFAULT:\r
++ $(MAKE) -C .. $@\r
+diff --git a/bindings/Makefile.local b/bindings/Makefile.local\r
+new file mode 100644\r
+index 0000000..f395c81\r
+--- /dev/null\r
++++ b/bindings/Makefile.local\r
+@@ -0,0 +1,18 @@\r
++# -*- makefile -*-\r
++\r
++dir := bindings\r
++\r
++# force the shared library to be build\r
++ruby-bindings: lib/libnotmuch.so\r
++ifeq ($(HAVE_RUBY_DEV),1)\r
++ cd $(dir)/ruby && ruby extconf.rb\r
++ $(MAKE) -C $(dir)/ruby\r
++else\r
++ @echo Missing dependency, skipping ruby bindings\r
++endif\r
++\r
++CLEAN += $(patsubst %,$(dir)/ruby/%, \\r
++ Makefile database.o directory.o filenames.o\\r
++ init.o message.o messages.o mkmf.log notmuch.so query.o \\r
++ status.o tags.o thread.o threads.o)\r
++\r
+diff --git a/configure b/configure\r
+index d14e7d1..7df3b29 100755\r
+--- a/configure\r
++++ b/configure\r
+@@ -21,6 +21,7 @@ srcdir=$(dirname "$0")\r
+ \r
+ subdirs="util compat lib parse-time-string completion doc emacs"\r
+ subdirs="${subdirs} performance-test test test/test-databases"\r
++subdirs="${subdirs} bindings"\r
+ \r
+ # For a non-srcdir configure invocation (such as ../configure), create\r
+ # the directory structure and copy Makefiles.\r
+@@ -426,6 +427,15 @@ else\r
+ have_doxygen=0\r
+ fi\r
+ \r
++printf "Checking for ruby development files... "\r
++if ruby -e "require 'mkmf'"> /dev/null 2>&1; then\r
++ printf "Yes.\n"\r
++ have_ruby_dev=1\r
++else\r
++ printf "No (skipping ruby bindings)\n"\r
++ have_ruby_dev=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
+@@ -848,6 +858,10 @@ HAVE_CANONICALIZE_FILE_NAME = ${have_canonicalize_file_name}\r
+ # build its own version)\r
+ HAVE_GETLINE = ${have_getline}\r
+ \r
++# Are the ruby development files (and ruby) available? If not skip\r
++# building/testing ruby bindings.\r
++HAVE_RUBY_DEV = ${have_ruby_dev}\r
++\r
+ # Whether the strcasestr function is available (if not, then notmuch will\r
+ # build its own version)\r
+ HAVE_STRCASESTR = ${have_strcasestr}\r
+@@ -958,6 +972,10 @@ NOTMUCH_HAVE_XAPIAN_COMPACT=${have_xapian_compact}\r
+ # Whether there's either sphinx or rst2man available for building\r
+ # documentation\r
+ NOTMUCH_HAVE_MAN=$((have_sphinx || have_rst2man))\r
++\r
++# Are the ruby development files (and ruby) available? If not skip\r
++# building/testing ruby bindings.\r
++NOTMUCH_HAVE_RUBY_DEV=${have_ruby_dev}\r
+ EOF\r
+ \r
+ # Finally, after everything configured, inform the user how to continue.\r
+-- \r
+2.1.3\r
+\r