--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id D82BD6DE092E\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Apr 2016 18:25:05 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.015\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.015 tagged_above=-999 required=5\r
+ tests=[AWL=-0.004, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id xjT_tt67AqQ5 for <notmuch@notmuchmail.org>;\r
+ Sat, 30 Apr 2016 18:24:58 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id D74D86DE02AF\r
+ for <notmuch@notmuchmail.org>; Sat, 30 Apr 2016 18:24:48 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1awg7n-0006bj-Rf; Sat, 30 Apr 2016 21:24:43 -0400\r
+Received: (nullmailer pid 29943 invoked by uid 1000);\r
+ Sun, 01 May 2016 01:24:43 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v3 03/11] lib/cli: add library API / CLI for compile time\r
+ options\r
+Date: Sat, 30 Apr 2016 22:24:31 -0300\r
+Message-Id: <1462065879-29860-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.0.rc3\r
+In-Reply-To: <1462065879-29860-1-git-send-email-david@tethera.net>\r
+References: <1462065879-29860-1-git-send-email-david@tethera.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 01 May 2016 01:25:05 -0000\r
+\r
+This is intentionally low tech; if we have more than two options it may\r
+make sense to build up what infrastructure is provided.\r
+---\r
+ doc/man1/notmuch-config.rst | 5 +++++\r
+ lib/Makefile.local | 1 +\r
+ lib/built-with.c | 33 +++++++++++++++++++++++++++++++++\r
+ lib/notmuch.h | 5 +++++\r
+ notmuch-config.c | 22 ++++++++++++++++++++++\r
+ test/T030-config.sh | 6 ++++--\r
+ test/T040-setup.sh | 6 ++++--\r
+ test/test-lib.sh | 6 ++++++\r
+ 8 files changed, 80 insertions(+), 4 deletions(-)\r
+ create mode 100644 lib/built-with.c\r
+\r
+diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst\r
+index 40c1272..26a8eb1 100644\r
+--- a/doc/man1/notmuch-config.rst\r
++++ b/doc/man1/notmuch-config.rst\r
+@@ -132,6 +132,11 @@ The available configuration items are described below.\r
+ \r
+ Default: ``gpg``.\r
+ \r
++ **built_with.<name>**\r
++\r
++ Compile time feature <name>. Current possibilities include\r
++ "compact" (see **notmuch-compact(1)**)\r
++ and "field_processor" (see **notmuch-search-terms(7)**).\r
+ \r
+ ENVIRONMENT\r
+ ===========\r
+diff --git a/lib/Makefile.local b/lib/Makefile.local\r
+index 3a07090..36c3924 100644\r
+--- a/lib/Makefile.local\r
++++ b/lib/Makefile.local\r
+@@ -39,6 +39,7 @@ libnotmuch_c_srcs = \\r
+ $(dir)/message-file.c \\r
+ $(dir)/messages.c \\r
+ $(dir)/sha1.c \\r
++ $(dir)/built-with.c \\r
+ $(dir)/tags.c\r
+ \r
+ libnotmuch_cxx_srcs = \\r
+diff --git a/lib/built-with.c b/lib/built-with.c\r
+new file mode 100644\r
+index 0000000..b619bed\r
+--- /dev/null\r
++++ b/lib/built-with.c\r
+@@ -0,0 +1,33 @@\r
++/* notmuch - Not much of an email program, (just index and search)\r
++ *\r
++ * Copyright © 2016 David Bremner\r
++ *\r
++ * This program is free software: you can redistribute it and/or modify\r
++ * it under the terms of the GNU General Public License as published by\r
++ * the Free Software Foundation, either version 3 of the License, or\r
++ * (at your option) any later version.\r
++ *\r
++ * This program is distributed in the hope that it will be useful,\r
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
++ * GNU General Public License for more details.\r
++ *\r
++ * You should have received a copy of the GNU General Public License\r
++ * along with this program. If not, see http://www.gnu.org/licenses/ .\r
++ *\r
++ * Author: David Bremner <david@tethera.net>\r
++ */\r
++\r
++#include "notmuch.h"\r
++#include "notmuch-private.h"\r
++\r
++notmuch_bool_t\r
++notmuch_built_with (const char *name) {\r
++ if (STRNCMP_LITERAL (name, "compact") == 0) {\r
++ return HAVE_XAPIAN_COMPACT;\r
++ } else if (STRNCMP_LITERAL (name, "field_processor") == 0) {\r
++ return HAVE_XAPIAN_FIELD_PROCESSOR;\r
++ } else {\r
++ return FALSE;\r
++ }\r
++}\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index cb46fc0..3a092ef 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -1838,6 +1838,11 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);\r
+ void\r
+ notmuch_filenames_destroy (notmuch_filenames_t *filenames);\r
+ \r
++/**\r
++ * interrogate the library for compile time features\r
++ */\r
++notmuch_bool_t\r
++notmuch_built_with (const char *name);\r
+ /* @} */\r
+ \r
+ NOTMUCH_END_DECLS\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index d252bb2..97a46fa 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -750,6 +750,8 @@ _item_split (char *item, char **group, char **key)\r
+ return 0;\r
+ }\r
+ \r
++#define BUILT_WITH_PREFIX "built_with."\r
++\r
+ static int\r
+ notmuch_config_command_get (notmuch_config_t *config, char *item)\r
+ {\r
+@@ -773,6 +775,9 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)\r
+ tags = notmuch_config_get_new_tags (config, &length);\r
+ for (i = 0; i < length; i++)\r
+ printf ("%s\n", tags[i]);\r
++ } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {\r
++ printf ("%s\n",\r
++ notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");\r
+ } else {\r
+ char **value;\r
+ size_t i, length;\r
+@@ -804,6 +809,11 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char\r
+ {\r
+ char *group, *key;\r
+ \r
++ if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {\r
++ fprintf (stderr, "Error: read only option: %s\n", item);\r
++ return 1;\r
++ }\r
++\r
+ if (_item_split (item, &group, &key))\r
+ return 1;\r
+ \r
+@@ -830,6 +840,17 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char\r
+ return notmuch_config_save (config);\r
+ }\r
+ \r
++static\r
++void\r
++_notmuch_config_list_options () {\r
++ printf("%scompact=%s\n",\r
++ BUILT_WITH_PREFIX,\r
++ notmuch_built_with ("compact") ? "true" : "false");\r
++ printf("%sfield_processor=%s\n",\r
++ BUILT_WITH_PREFIX,\r
++ notmuch_built_with ("field_processor") ? "true" : "false");\r
++}\r
++\r
+ static int\r
+ notmuch_config_command_list (notmuch_config_t *config)\r
+ {\r
+@@ -865,6 +886,7 @@ notmuch_config_command_list (notmuch_config_t *config)\r
+ \r
+ g_strfreev (groups);\r
+ \r
++ _notmuch_config_list_options ();\r
+ return 0;\r
+ }\r
+ \r
+diff --git a/test/T030-config.sh b/test/T030-config.sh\r
+index f404908..a4e24c3 100755\r
+--- a/test/T030-config.sh\r
++++ b/test/T030-config.sh\r
+@@ -44,7 +44,7 @@ test_expect_equal "$(notmuch config get foo.nonexistent)" ""\r
+ \r
+ test_begin_subtest "List all items"\r
+ notmuch config set database.path "/canonical/path"\r
+-output=$(notmuch config list)\r
++output=$(notmuch config list | notmuch_options_sanitize)\r
+ test_expect_equal "$output" "\\r
+ database.path=/canonical/path\r
+ user.name=Notmuch Test Suite\r
+@@ -56,7 +56,9 @@ search.exclude_tags=\r
+ maildir.synchronize_flags=true\r
+ crypto.gpg_path=gpg\r
+ foo.string=this is another string value\r
+-foo.list=this;is another;list value;"\r
++foo.list=this;is another;list value;\r
++built_with.compact=something\r
++built_with.field_processor=something"\r
+ \r
+ test_begin_subtest "Top level --config=FILE option"\r
+ cp "${NOTMUCH_CONFIG}" alt-config\r
+diff --git a/test/T040-setup.sh b/test/T040-setup.sh\r
+index cf0c00b..be2f0db 100755\r
+--- a/test/T040-setup.sh\r
++++ b/test/T040-setup.sh\r
+@@ -19,7 +19,7 @@ another.suite@example.com\r
+ foo bar\r
+ baz\r
+ EOF\r
+-output=$(notmuch --config=new-notmuch-config config list)\r
++output=$(notmuch --config=new-notmuch-config config list | notmuch_built_with_sanitize)\r
+ test_expect_equal "$output" "\\r
+ database.path=/path/to/maildir\r
+ user.name=Test Suite\r
+@@ -29,6 +29,8 @@ new.tags=foo;bar;\r
+ new.ignore=\r
+ search.exclude_tags=baz;\r
+ maildir.synchronize_flags=true\r
+-crypto.gpg_path=gpg"\r
++crypto.gpg_path=gpg\r
++built_with.compact=something\r
++built_with.field_processor=something"\r
+ \r
+ test_done\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index ac04b15..09f8731 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -733,6 +733,12 @@ notmuch_uuid_sanitize ()\r
+ {\r
+ sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g'\r
+ }\r
++\r
++notmuch_built_with_sanitize ()\r
++{\r
++ sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'\r
++}\r
++\r
+ # End of notmuch helper functions\r
+ \r
+ # Use test_set_prereq to tell that a particular prerequisite is available.\r
+-- \r
+2.8.0.rc3\r
+\r