]> git.eshelyaron.com Git - emacs.git/commitdiff
Port better to AIX 7.3 with -lz but not zlib.h
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Jan 2025 19:29:59 +0000 (11:29 -0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 20 Jan 2025 18:51:28 +0000 (19:51 +0100)
* configure.ac (HAVE_ZLIB, LIBZ):
Define only if zlib.h can be included (Bug#75667).

(cherry picked from commit a94988c01d45e4e494789d8715eed7ff7b383341)

configure.ac

index c0263629999c3ed6c0529cac5e04b09898a93992..64d2fcd2aba10877a0b0770b0c14bf9c01c3fcd7 100644 (file)
@@ -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 <zlib.h>
+                                         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