changeset 48262:ee64cb4455a9

8175795: configure should verify that system zlib contains needed functionality Reviewed-by: erikj
author ihse
date Mon, 04 Dec 2017 19:10:15 +0100
parents 14cd5bd01d81
children 56d3576aadd5 f27aad5782da
files make/autoconf/generated-configure.sh make/autoconf/lib-bundled.m4
diffstat 2 files changed, 71 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/make/autoconf/generated-configure.sh	Mon Dec 04 19:08:56 2017 +0100
+++ b/make/autoconf/generated-configure.sh	Mon Dec 04 19:10:15 2017 +0100
@@ -5159,7 +5159,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1512085548
+DATE_WHEN_GENERATED=1512410983
 
 ###############################################################################
 #
@@ -66263,23 +66263,6 @@
 fi
 
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which libpng to use" >&5
-$as_echo_n "checking for which libpng to use... " >&6; }
-
-  # default is bundled
-  DEFAULT_LIBPNG=bundled
-  # if user didn't specify, use DEFAULT_LIBPNG
-  if test "x${with_libpng}" = "x"; then
-    with_libpng=${DEFAULT_LIBPNG}
-  fi
-
-  if test "x${with_libpng}" = "xbundled"; then
-    USE_EXTERNAL_LIBPNG=false
-    PNG_CFLAGS=""
-    PNG_LIBS=""
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: bundled" >&5
-$as_echo "bundled" >&6; }
-  elif test "x${with_libpng}" = "xsystem"; then
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PNG" >&5
@@ -66347,6 +66330,23 @@
 $as_echo "yes" >&6; }
 	LIBPNG_FOUND=yes
 fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which libpng to use" >&5
+$as_echo_n "checking for which libpng to use... " >&6; }
+
+  # default is bundled
+  DEFAULT_LIBPNG=bundled
+  # if user didn't specify, use DEFAULT_LIBPNG
+  if test "x${with_libpng}" = "x"; then
+    with_libpng=${DEFAULT_LIBPNG}
+  fi
+
+  if test "x${with_libpng}" = "xbundled"; then
+    USE_EXTERNAL_LIBPNG=false
+    PNG_CFLAGS=""
+    PNG_LIBS=""
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: bundled" >&5
+$as_echo "bundled" >&6; }
+  elif test "x${with_libpng}" = "xsystem"; then
     if test "x${LIBPNG_FOUND}" = "xyes"; then
       # PKG_CHECK_MODULES will set PNG_CFLAGS and PNG_LIBS
       USE_EXTERNAL_LIBPNG=true
@@ -66444,6 +66444,40 @@
       USE_EXTERNAL_LIBZ=true
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: system" >&5
 $as_echo "system" >&6; }
+
+      if test "x$USE_EXTERNAL_LIBPNG" != "xtrue"; then
+        # If we use bundled libpng, we must verify that we have a proper zlib.
+        # For instance zlib-ng has had issues with inflateValidate().
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for system zlib functionality" >&5
+$as_echo_n "checking for system zlib functionality... " >&6; }
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h"
+int
+main ()
+{
+
+                #if ZLIB_VERNUM >= 0x1281
+                  inflateValidate(NULL, 0);
+                #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+else
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: not ok" >&5
+$as_echo "not ok" >&6; }
+                as_fn_error $? "System zlib not working correctly" "$LINENO" 5
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+      fi
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: system not found" >&5
 $as_echo "system not found" >&6; }
--- a/make/autoconf/lib-bundled.m4	Mon Dec 04 19:08:56 2017 +0100
+++ b/make/autoconf/lib-bundled.m4	Mon Dec 04 19:10:15 2017 +0100
@@ -113,6 +113,7 @@
   AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng],
      [use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 
+  PKG_CHECK_MODULES(PNG, libpng, [LIBPNG_FOUND=yes], [LIBPNG_FOUND=no])
   AC_MSG_CHECKING([for which libpng to use])
 
   # default is bundled
@@ -128,7 +129,6 @@
     PNG_LIBS=""
     AC_MSG_RESULT([bundled])
   elif test "x${with_libpng}" = "xsystem"; then
-    PKG_CHECK_MODULES(PNG, libpng, [LIBPNG_FOUND=yes], [LIBPNG_FOUND=no])
     if test "x${LIBPNG_FOUND}" = "xyes"; then
       # PKG_CHECK_MODULES will set PNG_CFLAGS and PNG_LIBS
       USE_EXTERNAL_LIBPNG=true
@@ -183,6 +183,24 @@
     if test "x${ZLIB_FOUND}" = "xyes"; then
       USE_EXTERNAL_LIBZ=true
       AC_MSG_RESULT([system])
+
+      if test "x$USE_EXTERNAL_LIBPNG" != "xtrue"; then
+        # If we use bundled libpng, we must verify that we have a proper zlib.
+        # For instance zlib-ng has had issues with inflateValidate().
+        AC_MSG_CHECKING([for system zlib functionality])
+        AC_COMPILE_IFELSE(
+            [AC_LANG_PROGRAM([#include "zlib.h"], [
+                #if ZLIB_VERNUM >= 0x1281
+                  inflateValidate(NULL, 0);
+                #endif
+            ])],
+            [AC_MSG_RESULT([ok])],
+            [
+                AC_MSG_RESULT([not ok])
+                AC_MSG_ERROR([System zlib not working correctly])
+            ]
+        )
+      fi
     else
       AC_MSG_RESULT([system not found])
       AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])