[PATCH 1/2] configure: add a fallback check for zlib
authorXīcò <xico@atelo.org>
Sat, 10 May 2014 20:27:25 +0000 (13:27 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:02:38 +0000 (10:02 -0800)
61/1ab33b7cdcf7de3fc6c178a106a7846fb6d674 [new file with mode: 0644]

diff --git a/61/1ab33b7cdcf7de3fc6c178a106a7846fb6d674 b/61/1ab33b7cdcf7de3fc6c178a106a7846fb6d674
new file mode 100644 (file)
index 0000000..f0a1877
--- /dev/null
@@ -0,0 +1,118 @@
+Return-Path: <xico@atelo.org>\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 212AC431FC0\r
+       for <notmuch@notmuchmail.org>; Sat, 10 May 2014 13:27:53 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.001\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
+       tests=[UNPARSEABLE_RELAY=0.001] 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 NKmgEIamgFJc for <notmuch@notmuchmail.org>;\r
+       Sat, 10 May 2014 13:27:45 -0700 (PDT)\r
+Received: from mail.atelo.org (atelo.org [192.95.27.91])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 87843431FBF\r
+       for <notmuch@notmuchmail.org>; Sat, 10 May 2014 13:27:45 -0700 (PDT)\r
+Received: from coyotlan.atelo.org (ovo.atelo.org [192.168.1.7]);\r
+       by mail.atelo.org (OpenSMTPD) with ESMTP id ba5eae50;\r
+       Sat, 10 May 2014 20:27:13 +0000 (UTC)\r
+Received: from localhost (1001@localhost [local]);\r
+       by localhost (OpenSMTPD) with ESMTPA id e9eaaa2f;\r
+       Sat, 10 May 2014 13:27:41 -0700 (PDT)\r
+User-Agent: OpenSMTPD enqueuer (Demoostik)\r
+From: =?UTF-8?q?X=C4=ABc=C3=B2?= <xico@atelo.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] configure: add a fallback check for zlib\r
+Date: Sat, 10 May 2014 13:27:25 -0700\r
+Message-Id: <1399753646-3026-1-git-send-email-xico@atelo.org>\r
+X-Mailer: git-send-email 1.9.2\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: Sat, 10 May 2014 20:27:53 -0000\r
+\r
+Since zlib is part of the base system, FreeBSD chose not to register it\r
+in pkg-config through zlib.pc. As a fallback test, configure will build\r
+and run a zlib version check and make sure the header and library\r
+versions are compatible.\r
+---\r
+ compat/have_zlib.c |  6 ++++++\r
+ configure          | 21 ++++++++++++++++-----\r
+ 2 files changed, 22 insertions(+), 5 deletions(-)\r
+ create mode 100644 compat/have_zlib.c\r
+\r
+diff --git a/compat/have_zlib.c b/compat/have_zlib.c\r
+new file mode 100644\r
+index 0000000..abaeedd\r
+--- /dev/null\r
++++ b/compat/have_zlib.c\r
+@@ -0,0 +1,6 @@\r
++#include <zlib.h>\r
++\r
++int main(void)\r
++{\r
++    return (ZLIB_VERNUM) < (MINVER) || zlibVersion()[0] != (ZLIB_VERSION)[0];\r
++}\r
+diff --git a/configure b/configure\r
+index 9bde2eb..7a11ded 100755\r
+--- a/configure\r
++++ b/configure\r
+@@ -340,16 +340,27 @@ else\r
+     errors=$((errors + 1))\r
+ fi\r
\r
+-printf "Checking for zlib (>= 1.2.5.2)... "\r
++zv1=1 zv2=2 zv3=5 zv4=1\r
++printf "Checking for zlib (>= $zv1.$zv2.$zv3.$zv4)... "\r
+ have_zlib=0\r
+-if pkg-config --atleast-version=1.2.5.2 zlib; then\r
++if pkg-config --atleast-version=$zv1.$zv2.$zv3.$zv4 zlib; then\r
+     printf "Yes.\n"\r
+     have_zlib=1\r
+     zlib_cflags=$(pkg-config --cflags zlib)\r
+     zlib_ldflags=$(pkg-config --libs zlib)\r
+ else\r
+-    printf "No.\n"\r
+-    errors=$((errors + 1))\r
++    # Try finding zlib directly (e.g. on FreeBSD)\r
++    zlib_cflags=\r
++    zlib_ldflags=-lz\r
++    if ${CC} ${zlib_cflags} -DMINVER=0x$zv1$zv2$zv3$zv4 -o compat/have_zlib "$srcdir"/compat/have_zlib.c ${zlib_ldflags} > /dev/null 2>&1 && ./compat/have_zlib\r
++    then\r
++        printf "Yes.\n"\r
++        have_zlib=1\r
++    else\r
++        printf "No.\n"\r
++        errors=$((errors + 1))\r
++    fi\r
++    rm -f compat/have_zlib\r
+ fi\r
\r
+ printf "Checking for talloc development files... "\r
+@@ -509,7 +520,7 @@ EOF\r
+       echo "  http://xapian.org/"\r
+     fi\r
+     if [ $have_zlib -eq 0 ]; then\r
+-      echo "  zlib library (>= version 1.2.5.2, including development files such as headers)"\r
++      echo "  zlib library (>= version $zv1.$zv2.$zv3.$zv4, including development files such as headers)"\r
+       echo "  http://zlib.net/"\r
+       echo\r
+     fi\r
+-- \r
+1.9.2\r
+\r