[PATCH] Fallback check for zlib.

Tomi Ollila tomi.ollila at iki.fi
Sat May 10 00:58:12 PDT 2014


On Sat, May 10 2014, Xīcò <xico at atelo.org> wrote:

> ---

I must say I like the patch. One thing I would change:

+    return (ZLIB_VERNUM) < (MINVER) || zlibVersion()[0] != (ZLIB_VERSION)[0];

i.e. short-circuiting potential failure before executing zlibVersion()...

(parenthesising macros is just extra fanciness I thought just before
sending this email ;D)

Tomi

>  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


More information about the notmuch mailing list