changeset 5351:fc52d0a1fcda

7110151: Use underlying platform's zlib library for Java zlib support Summary: Make SYSTEM_ZLIB more flexible by using ZLIB_{CFLAGS,LIBS} and building on more than just MACOSX. Reviewed-by: sherman, alanb
author andrew
date Wed, 19 Sep 2012 17:56:52 +0100
parents c241d4a80272
children 2699f1b8b94b
files make/com/sun/java/pack/Makefile make/common/Program.gmk make/common/shared/Defs-linux.gmk make/common/shared/Defs-macosx.gmk make/common/shared/Defs-solaris.gmk make/java/jli/Makefile make/java/zip/Makefile make/jdk_generic_profile.sh make/sun/splashscreen/Makefile src/share/native/com/sun/java/util/jar/pack/defines.h src/share/native/java/util/zip/Adler32.c src/share/native/java/util/zip/CRC32.c src/share/native/java/util/zip/Deflater.c src/share/native/java/util/zip/Inflater.c src/share/native/java/util/zip/zip_util.c
diffstat 15 files changed, 53 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/make/com/sun/java/pack/Makefile	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/com/sun/java/pack/Makefile	Wed Sep 19 17:56:52 2012 +0100
@@ -75,8 +75,8 @@
   OTHER_CXXFLAGS += $(ZINCLUDE)
   LDDFLAGS += $(ZIPOBJS)
  else
-  LDDFLAGS += -lz
-  OTHER_CXXFLAGS += -DSYSTEM_ZLIB
+  LDDFLAGS += $(ZLIB_LIBS)
+  OTHER_CXXFLAGS += $(ZLIB_CFLAGS) -DSYSTEM_ZLIB
  endif
 else
   OTHER_CXXFLAGS += -DNO_ZLIB -DUNPACK_JNI
--- a/make/common/Program.gmk	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/common/Program.gmk	Wed Sep 19 17:56:52 2012 +0100
@@ -91,7 +91,7 @@
   LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
 
   ifeq ($(SYSTEM_ZLIB),true)
-    OTHER_LDLIBS += -lz
+    OTHER_LDLIBS += $(ZLIB_LIBS)
   endif # SYSTEM_ZLIB
 endif # PLATFORM
 
--- a/make/common/shared/Defs-linux.gmk	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/common/shared/Defs-linux.gmk	Wed Sep 19 17:56:52 2012 +0100
@@ -129,6 +129,11 @@
 BUILD_HEADLESS = true
 LIBM=-lm
 
+# Set ZLIB_LIBS if not already set
+ifeq ("$(ZLIB_LIBS)", "")
+  ZLIB_LIBS=-lz
+endif
+
 # GCC29_COMPILER_PATH: is the path to where the gcc 2.9 compiler is installed
 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
 ifdef ALT_GCC29_COMPILER_PATH
--- a/make/common/shared/Defs-macosx.gmk	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/common/shared/Defs-macosx.gmk	Wed Sep 19 17:56:52 2012 +0100
@@ -143,6 +143,11 @@
   _CUPS_HEADERS_PATH=$(PACKAGE_PATH)/include
 endif
 
+# Set ZLIB_LIBS if not already set
+ifeq ("$(ZLIB_LIBS)", "")
+  ZLIB_LIBS=-lz
+endif
+
 # Import JDK images allow for partial builds, components not built are
 #    imported (or copied from) these import areas when needed.
 
--- a/make/common/shared/Defs-solaris.gmk	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/common/shared/Defs-solaris.gmk	Wed Sep 19 17:56:52 2012 +0100
@@ -140,6 +140,11 @@
 
 _CUPS_HEADERS_PATH=/opt/sfw/cups/include
 
+# Set ZLIB_LIBS if not already set
+ifeq ("$(ZLIB_LIBS)", "")
+  ZLIB_LIBS=-lz
+endif
+
 # Import JDK images allow for partial builds, components not built are
 #    imported (or copied from) these import areas when needed.
 
--- a/make/java/jli/Makefile	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/java/jli/Makefile	Wed Sep 19 17:56:52 2012 +0100
@@ -46,6 +46,8 @@
 
 ifneq ($(SYSTEM_ZLIB),true)
   ZIP_SRC = $(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+else # SYSTEM_ZLIB
+  OTHER_CFLAGS += $(ZLIB_CFLAGS)
 endif #SYSTEM_ZLIB
 LAUNCHER_SHARE_SRC = $(SHARE_SRC)/bin
 
@@ -162,7 +164,7 @@
 ifneq ($(SYSTEM_ZLIB),true)
   OTHER_INCLUDES += -I$(ZIP_SRC)
 else # !SYSTEM_ZLIB
-  LDLIBS += -lz
+  LDLIBS += $(ZLIB_LIBS)
 endif # SYSTEM_ZLIB
 
 #
--- a/make/java/zip/Makefile	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/java/zip/Makefile	Wed Sep 19 17:56:52 2012 +0100
@@ -56,6 +56,10 @@
   endif
 endif
 
+ifeq ($(SYSTEM_ZLIB),true)
+  OTHER_CFLAGS += $(ZLIB_CFLAGS)
+endif
+
 #
 # Library to compile.
 #
@@ -90,7 +94,7 @@
 # Link to JVM library for JVM_Zip* functions
 #
 ifeq ($(SYSTEM_ZLIB),true)
-OTHER_LDLIBS = -lz
+OTHER_LDLIBS = $(ZLIB_LIBS)
 else
 OTHER_LDLIBS = $(JVMLIB)
 endif
--- a/make/jdk_generic_profile.sh	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/jdk_generic_profile.sh	Wed Sep 19 17:56:52 2012 +0100
@@ -378,3 +378,22 @@
     export LLVM_LIBS
   fi
 fi
+
+# Export variables for system zlib
+# ZLIB_CFLAGS and ZLIB_LIBS tell the compiler how to compile and
+# link against zlib
+pkgconfig=$(which pkg-config 2>/dev/null)
+if [ -x "${pkgconfig}" ] ; then
+  if [ "${ZLIB_CFLAGS}" = "" ] ; then
+    ZLIB_CFLAGS=$("${pkgconfig}" --cflags zlib)
+  fi
+  if [ "${ZLIB_LIBS}" = "" ] ; then
+    ZLIB_LIBS=$("${pkgconfig}" --libs zlib)
+  fi
+fi
+if [ "${ZLIB_LIBS}" = "" ] ; then
+    ZLIB_LIBS="-lz"
+fi
+export ZLIB_CFLAGS
+export ZLIB_LIBS
+
--- a/make/sun/splashscreen/Makefile	Wed Sep 19 00:43:07 2012 +0100
+++ b/make/sun/splashscreen/Makefile	Wed Sep 19 17:56:52 2012 +0100
@@ -126,7 +126,8 @@
 ifneq ($(SYSTEM_ZLIB),true)
   CPPFLAGS += -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
 else
-  OTHER_LDLIBS += -lz
+  OTHER_CFLAGS += $(ZLIB_CFLAGS)
+  OTHER_LDLIBS += $(ZLIB_LIBS)
 endif
 
 # Shun the less than portable MMX assembly code in pnggccrd.c,
--- a/src/share/native/com/sun/java/util/jar/pack/defines.h	Wed Sep 19 00:43:07 2012 +0100
+++ b/src/share/native/com/sun/java/util/jar/pack/defines.h	Wed Sep 19 17:56:52 2012 +0100
@@ -93,7 +93,7 @@
 // bytes and byte arrays
 
 typedef unsigned int uint;
-#if !defined(MACOSX) || (defined(MACOSX) && defined(NO_ZLIB))
+#if defined(NO_ZLIB)
 #ifdef _LP64
 typedef unsigned int uLong; // Historical zlib, should be 32-bit.
 #else
--- a/src/share/native/java/util/zip/Adler32.c	Wed Sep 19 00:43:07 2012 +0100
+++ b/src/share/native/java/util/zip/Adler32.c	Wed Sep 19 17:56:52 2012 +0100
@@ -29,7 +29,7 @@
 
 #include "jni.h"
 #include "jni_util.h"
-#include "zlib.h"
+#include <zlib.h>
 
 #include "java_util_zip_Adler32.h"
 
--- a/src/share/native/java/util/zip/CRC32.c	Wed Sep 19 00:43:07 2012 +0100
+++ b/src/share/native/java/util/zip/CRC32.c	Wed Sep 19 17:56:52 2012 +0100
@@ -29,7 +29,7 @@
 
 #include "jni.h"
 #include "jni_util.h"
-#include "zlib.h"
+#include <zlib.h>
 
 #include "java_util_zip_CRC32.h"
 
--- a/src/share/native/java/util/zip/Deflater.c	Wed Sep 19 00:43:07 2012 +0100
+++ b/src/share/native/java/util/zip/Deflater.c	Wed Sep 19 17:56:52 2012 +0100
@@ -32,7 +32,7 @@
 #include "jlong.h"
 #include "jni.h"
 #include "jni_util.h"
-#include "zlib.h"
+#include <zlib.h>
 
 #include "java_util_zip_Deflater.h"
 
--- a/src/share/native/java/util/zip/Inflater.c	Wed Sep 19 00:43:07 2012 +0100
+++ b/src/share/native/java/util/zip/Inflater.c	Wed Sep 19 17:56:52 2012 +0100
@@ -35,7 +35,7 @@
 #include "jni.h"
 #include "jvm.h"
 #include "jni_util.h"
-#include "zlib.h"
+#include <zlib.h>
 #include "java_util_zip_Inflater.h"
 
 #define ThrowDataFormatException(env, msg) \
--- a/src/share/native/java/util/zip/zip_util.c	Wed Sep 19 00:43:07 2012 +0100
+++ b/src/share/native/java/util/zip/zip_util.c	Wed Sep 19 17:56:52 2012 +0100
@@ -44,7 +44,7 @@
 #include "io_util.h"
 #include "io_util_md.h"
 #include "zip_util.h"
-#include "zlib.h"
+#include <zlib.h>
 
 #ifdef _ALLBSD_SOURCE
 #define off64_t off_t