From 3527d1aca517f7efe91c0841f271c56d02a73718 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 19 Jan 2025 11:29:59 -0800 Subject: [PATCH] Port better to AIX 7.3 with -lz but not zlib.h * configure.ac (HAVE_ZLIB, LIBZ): Define only if zlib.h can be included (Bug#75667). (cherry picked from commit a94988c01d45e4e494789d8715eed7ff7b383341) --- configure.ac | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index c0263629999..64d2fcd2aba 100644 --- a/configure.ac +++ b/configure.ac @@ -5069,22 +5069,29 @@ AC_SUBST([LCMS2_LIBS]) HAVE_ZLIB=no LIBZ= -if test "${with_zlib}" != "no"; then - OLIBS=$LIBS - AC_SEARCH_LIBS([inflateEnd], [z], [HAVE_ZLIB=yes]) - LIBS=$OLIBS - case $ac_cv_search_inflateEnd in - -*) LIBZ=$ac_cv_search_inflateEnd ;; - esac -fi -if test "${HAVE_ZLIB}" = "yes"; then - AC_DEFINE([HAVE_ZLIB], [1], - [Define to 1 if you have the zlib library (-lz).]) - ### mingw32 doesn't use -lz, since it loads the library dynamically. - if test "${opsys}" = "mingw32"; then - LIBZ= - fi -fi +AS_IF([test "${with_zlib}" != "no"], + [AC_CACHE_CHECK([for library containing inflateEnd], + [emacs_cv_libz], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include + z_stream stream;]], + [[return inflateEnd (&stream);]])]) + OLIBS=$LIBS + for emacs_cv_libz in '' -lz no; do + test "$emacs_cv_libz" = no && break + LIBS="$emacs_cv_libz $OLIBS" + AC_LINK_IFELSE([], [break]) + done + LIBS=$OLIBS]) + + AS_CASE([$emacs_cv_libz], + [-* | ''], + [# mingw32 doesn't use -lz, since it loads the library dynamically. + AS_CASE([$opsys], + [mingw32], [LIBZ=], + [LIBZ=$emacs_cv_libz]) + HAVE_ZLIB=yes + AC_DEFINE([HAVE_ZLIB], [1], + [Define to 1 if you have the zlib library (-lz).])])]) AC_SUBST([LIBZ]) ### Dynamic library support -- 2.39.5