From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <xico@atelo.org>
Received: from localhost (localhost [127.0.0.1])
	by olra.theworths.org (Postfix) with ESMTP id 3F17F431FC7
	for <notmuch@notmuchmail.org>; Fri,  9 May 2014 22:34:54 -0700 (PDT)
X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
X-Spam-Flag: NO
X-Spam-Score: 0.001
X-Spam-Level: 
X-Spam-Status: No, score=0.001 tagged_above=-999 required=5
	tests=[UNPARSEABLE_RELAY=0.001] autolearn=disabled
Received: from olra.theworths.org ([127.0.0.1])
	by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id BbI+kOjgdeHr for <notmuch@notmuchmail.org>;
	Fri,  9 May 2014 22:34:49 -0700 (PDT)
Received: from mail.atelo.org (atelo.org [192.95.27.91])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by olra.theworths.org (Postfix) with ESMTPS id 9E97D431FBF
	for <notmuch@notmuchmail.org>; Fri,  9 May 2014 22:34:49 -0700 (PDT)
Received: from coyotlan.atelo.org (ovo.atelo.org [192.168.1.7]);
	by mail.atelo.org (OpenSMTPD) with ESMTP id 3b2ff962;
	Sat, 10 May 2014 05:34:19 +0000 (UTC)
Received: from localhost (1001@localhost [local]);
	by localhost (OpenSMTPD) with ESMTPA id 44c5e8f8;
	Fri, 9 May 2014 22:34:46 -0700 (PDT)
User-Agent: OpenSMTPD enqueuer (Demoostik)
From: =?UTF-8?q?X=C4=ABc=C3=B2?= <xico@atelo.org>
To: notmuch@notmuchmail.org
Subject: [PATCH] Fallback check for zlib.
Date: Fri,  9 May 2014 22:33:43 -0700
Message-Id: <1399700023-8041-2-git-send-email-xico@atelo.org>
X-Mailer: git-send-email 1.9.2
In-Reply-To: <1399700023-8041-1-git-send-email-xico@atelo.org>
References: <874n0y5qo5.fsf@maritornes.cs.unb.ca>
	<1399700023-8041-1-git-send-email-xico@atelo.org>
Cc: Tomi Ollila <tomi.ollila@iki.fi>
X-BeenThere: notmuch@notmuchmail.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: "Use and development of the notmuch mail system."
	<notmuch.notmuchmail.org>
List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
	<mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
List-Archive: <http://notmuchmail.org/pipermail/notmuch>
List-Post: <mailto:notmuch@notmuchmail.org>
List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
	<mailto:notmuch-request@notmuchmail.org?subject=subscribe>
X-List-Received-Date: Sat, 10 May 2014 05:34:54 -0000

---
 compat/have_zlib.c |  6 ++++++
 configure          | 21 ++++++++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)
 create mode 100644 compat/have_zlib.c

diff --git a/compat/have_zlib.c b/compat/have_zlib.c
new file mode 100644
index 0000000..998c697
--- /dev/null
+++ b/compat/have_zlib.c
@@ -0,0 +1,6 @@
+#include <zlib.h>
+
+int main(void)
+{
+    return zlibVersion()[0] != ZLIB_VERSION[0] || ZLIB_VERNUM < MINVER;
+}
diff --git a/configure b/configure
index 9bde2eb..7a11ded 100755
--- a/configure
+++ b/configure
@@ -340,16 +340,27 @@ else
     errors=$((errors + 1))
 fi
 
-printf "Checking for zlib (>= 1.2.5.2)... "
+zv1=1 zv2=2 zv3=5 zv4=1
+printf "Checking for zlib (>= $zv1.$zv2.$zv3.$zv4)... "
 have_zlib=0
-if pkg-config --atleast-version=1.2.5.2 zlib; then
+if pkg-config --atleast-version=$zv1.$zv2.$zv3.$zv4 zlib; then
     printf "Yes.\n"
     have_zlib=1
     zlib_cflags=$(pkg-config --cflags zlib)
     zlib_ldflags=$(pkg-config --libs zlib)
 else
-    printf "No.\n"
-    errors=$((errors + 1))
+    # Try finding zlib directly (e.g. on FreeBSD)
+    zlib_cflags=
+    zlib_ldflags=-lz
+    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
+    then
+        printf "Yes.\n"
+        have_zlib=1
+    else
+        printf "No.\n"
+        errors=$((errors + 1))
+    fi
+    rm -f compat/have_zlib
 fi
 
 printf "Checking for talloc development files... "
@@ -509,7 +520,7 @@ EOF
 	echo "	http://xapian.org/"
     fi
     if [ $have_zlib -eq 0 ]; then
-	echo "	zlib library (>= version 1.2.5.2, including development files such as headers)"
+	echo "	zlib library (>= version $zv1.$zv2.$zv3.$zv4, including development files such as headers)"
 	echo "	http://zlib.net/"
 	echo
     fi
-- 
1.9.2