--- /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 arlo.cworth.org (Postfix) with ESMTP id 90C706DE13EA\r
+ for <notmuch@notmuchmail.org>; Wed, 20 May 2015 01:15:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.297\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.297 tagged_above=-999 required=5 tests=[AWL=0.287, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 jLMuswl6qLhB for <notmuch@notmuchmail.org>;\r
+ Wed, 20 May 2015 01:15:22 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id C42486DE13DA\r
+ for <notmuch@notmuchmail.org>; Wed, 20 May 2015 01:15:21 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1Yuz7m-0003UU-8B; Wed, 20 May 2015 08:13:10 +0000\r
+Received: (nullmailer pid 16941 invoked by uid 1000); Wed, 20 May 2015\r
+ 08:12:35 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, David Bremner <david@tethera.net>,\r
+ Ronny Chevalier <chevalier.ronny@gmail.com>\r
+Subject: [PATCH] configure: Add sanity checking for environment variables\r
+Date: Wed, 20 May 2015 10:12:31 +0200\r
+Message-Id: <1432109551-16861-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <m2617onuhh.fsf@guru.guru-group.fi>\r
+References: <m2617onuhh.fsf@guru.guru-group.fi>\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Wed, 20 May 2015 08:15:24 -0000\r
+\r
+Passing in environment variables incompatible with the compiler may\r
+cause other parts of the configure script to fail in hard to\r
+understand ways, so we abort early.\r
+---\r
+\r
+meh, the previous version was borken by lazy evaluation of CXXFLAGS\r
+using make syntax. Better suggestions for how to do this?\r
+\r
+ configure | 31 +++++++++++++++++++++++++++++--\r
+ 1 file changed, 29 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/configure b/configure\r
+index 4af7ba9..650b976 100755\r
+--- a/configure\r
++++ b/configure\r
+@@ -269,6 +269,35 @@ dependencies are available:\r
+ EOF\r
+ \r
+ errors=0\r
++printf "int main(void){return 0;}\n" > minimal.c\r
++\r
++printf "Sanity checking C compilation environment... "\r
++if ${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal > /dev/null 2>&1\r
++then\r
++ printf "OK.\n"\r
++else\r
++ printf "Fail.\n"\r
++ errors=$((errors + 1))\r
++fi\r
++\r
++printf "Sanity checking C++ compilation environment... "\r
++if ${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal > /dev/null 2>&1\r
++then\r
++ printf "OK.\n"\r
++else\r
++ printf "Fail.\n"\r
++ errors=$((errors + 1))\r
++fi\r
++\r
++if [ $errors -gt 0 ]; then\r
++ cat <<EOF\r
++*** Error: Initial sanity checking of environment failed. Please try\r
++running configure in a clean environment, and if the problem persists,\r
++report a bug.\r
++EOF\r
++ rm -f minimal minimal.c\r
++ exit 1\r
++fi\r
+ \r
+ if pkg-config --version > /dev/null 2>&1; then\r
+ have_pkg_config=1\r
+@@ -690,8 +719,6 @@ else\r
+ fi\r
+ rm -f compat/check_asctime\r
+ \r
+-printf "int main(void){return 0;}\n" > minimal.c\r
+-\r
+ printf "Checking for rpath support... "\r
+ if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1\r
+ then\r
+-- \r
+2.1.4\r
+\r