Try to fix libsplashscreen on mac. ihse-jdk-library-branch
authorihse
Fri, 04 May 2018 10:55:57 +0200
branchihse-jdk-library-branch
changeset 56527 0d55cbe2e63e
parent 56526 c13fb323b2fb
child 56528 0bedb8bb962b
Try to fix libsplashscreen on mac.
make/lib/Awt2dLibraries.gmk
src/java.desktop/macosx/native/libsplashscreen/libpng/zlib.h
src/java.desktop/macosx/native/libsplashscreen/libpng/zlibwrapper/zlib.h
--- a/make/lib/Awt2dLibraries.gmk	Fri May 04 10:09:27 2018 +0200
+++ b/make/lib/Awt2dLibraries.gmk	Fri May 04 10:55:57 2018 +0200
@@ -772,6 +772,17 @@
 
   ifeq ($(USE_EXTERNAL_LIBPNG), false)
     LIBSPLASHSCREEN_HEADER_DIRS += libsplashscreen/libpng
+
+    ifeq ($(OPENJDK_TARGET_OS), macosx)
+      ifeq ($(USE_EXTERNAL_LIBZ), true)
+        # When building our own libpng and using an external libz, we need to
+        # inject our own libz.h to tweak the exported ZLIB_VERNUM macro. See
+        # $(TOPDIR)/src/java.desktop/macosx/native/libsplashscreen/libpng/zlibwrapper/zlib.h
+        # for details. This must be specified with -iquote, not -I to avoid a
+        # circular include.
+        LIBSPLASHSCREEN_CFLAGS += -iquote $(TOPDIR)/src/$(MODULE)/macosx/native/libsplashscreen/libpng/zlibwrapper
+      endif
+    endif
   else
     LIBSPLASHSCREEN_EXCLUDES += libpng
   endif
@@ -804,18 +815,6 @@
     LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS)
   endif
 
-  ifeq ($(USE_EXTERNAL_LIBZ), true)
-    ifeq ($(OPENJDK_TARGET_OS), macosx)
-      ifeq ($(USE_EXTERNAL_LIBPNG), false)
-        # When building our own libpng and using an external libz, we need to
-        # inject our own libz.h to tweak the exported ZLIB_VERNUM macro. See
-        # $(TOPDIR)/src/java.desktop/macosx/native/libsplashscreen/libpng/zlib.h
-        # for details.
-        LIBSPLASHSCREEN_CFLAGS += -iquote $(TOPDIR)/src/$(MODULE)/macosx/native/libsplashscreen/libpng
-      endif
-    endif
-  endif
-
   LIBSPLASHSCREEN_LIBS :=
 
   ifeq ($(OPENJDK_TARGET_OS), macosx)
@@ -844,7 +843,7 @@
       EXCLUDE_FILES := imageioJPEG.c jpegdecoder.c pngtest.c, \
       EXCLUDES := $(LIBSPLASHSCREEN_EXCLUDES), \
       OPTIMIZATION := LOW, \
-      CFLAGS := $(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) \
+      CFLAGS := $(CFLAGS_JDKLIB) $(LIBSPLASHSCREEN_CFLAGS) \
           $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS) $(PNG_CFLAGS) $(LIBZ_CFLAGS), \
       EXTRA_HEADER_DIRS := $(LIBSPLASHSCREEN_HEADER_DIRS), \
       DISABLED_WARNINGS_gcc := sign-compare type-limits unused-result \
--- a/src/java.desktop/macosx/native/libsplashscreen/libpng/zlib.h	Fri May 04 10:09:27 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This header file is used to hijack the include of "zlib.h" from libpng on
- * Macos. We do that to be able to build on macos 10.13 or later, but still
- * keep binary compatibility with older versions (as specified to configure).
- *
- * The problem is that in 10.13, Macos shipped with a newer version of zlib,
- * which exports the function inflateValidate. There is a call to this
- * function in pngrutil.c, guarded by a preprocessor check of ZLIB_VERNUM being
- * high enough. If we compile this call in and link to the newer version of
- * zlib, we will get link errors if the code is executed on an older Mac with
- * an older version of zlib.
- *
- * The zlib.h header in Macos has been annotated with Macos specific macros that
- * guard these kinds of version specific APIs, but libpng is not using those
- * checks in its conditionals, just ZLIB_VERNUM. To fix this, we check for the
- * MAC_OS_X_VERSION_MIN_REQUIRED macro here and adjust the ZLIB_VERNUM to the
- # known version bundled with that release. This solution is certainly a hack,
- * but it seems the affected versions of zlib.h are compatible enough for this
- * to work.
- */
-
-#include <zlib.h>
-#include <AvailabilityMacros.h>
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
-#  undef ZLIB_VERNUM
-#  define ZLIB_VERNUM 0x1250
-#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13
-#  undef ZLIB_VERNUM
-#  define ZLIB_VERNUM 0x1280
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/macosx/native/libsplashscreen/libpng/zlibwrapper/zlib.h	Fri May 04 10:55:57 2018 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This header file is used to hijack the include of "zlib.h" from libpng on
+ * Macos. We do that to be able to build on macos 10.13 or later, but still
+ * keep binary compatibility with older versions (as specified to configure).
+ *
+ * The problem is that in 10.13, Macos shipped with a newer version of zlib,
+ * which exports the function inflateValidate. There is a call to this
+ * function in pngrutil.c, guarded by a preprocessor check of ZLIB_VERNUM being
+ * high enough. If we compile this call in and link to the newer version of
+ * zlib, we will get link errors if the code is executed on an older Mac with
+ * an older version of zlib.
+ *
+ * The zlib.h header in Macos has been annotated with Macos specific macros that
+ * guard these kinds of version specific APIs, but libpng is not using those
+ * checks in its conditionals, just ZLIB_VERNUM. To fix this, we check for the
+ * MAC_OS_X_VERSION_MIN_REQUIRED macro here and adjust the ZLIB_VERNUM to the
+ # known version bundled with that release. This solution is certainly a hack,
+ * but it seems the affected versions of zlib.h are compatible enough for this
+ * to work.
+ */
+
+#include <zlib.h>
+#include <AvailabilityMacros.h>
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
+#  undef ZLIB_VERNUM
+#  define ZLIB_VERNUM 0x1250
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13
+#  undef ZLIB_VERNUM
+#  define ZLIB_VERNUM 0x1280
+#endif