7110151: Use underlying platform's zlib library for Java zlib support
authorandrew
Wed, 15 Aug 2012 14:35:36 +0100
changeset 13567 b124faa29aef
parent 13566 4b4e31014e90
child 13568 ce5ab758aeb5
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
jdk/make/com/sun/java/pack/Makefile
jdk/make/common/Program.gmk
jdk/make/common/shared/Defs-linux.gmk
jdk/make/common/shared/Defs-macosx.gmk
jdk/make/common/shared/Defs-solaris.gmk
jdk/make/java/jli/Makefile
jdk/make/java/zip/Makefile
jdk/make/jdk_generic_profile.sh
jdk/make/sun/splashscreen/Makefile
jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
jdk/src/share/native/java/util/zip/Adler32.c
jdk/src/share/native/java/util/zip/CRC32.c
jdk/src/share/native/java/util/zip/Deflater.c
jdk/src/share/native/java/util/zip/Inflater.c
jdk/src/share/native/java/util/zip/zip_util.c
--- a/jdk/make/com/sun/java/pack/Makefile	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/com/sun/java/pack/Makefile	Wed Aug 15 14:35:36 2012 +0100
@@ -77,8 +77,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/jdk/make/common/Program.gmk	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/common/Program.gmk	Wed Aug 15 14:35:36 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
 endif
 
--- a/jdk/make/common/shared/Defs-linux.gmk	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/common/shared/Defs-linux.gmk	Wed Aug 15 14:35:36 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/jdk/make/common/shared/Defs-macosx.gmk	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/common/shared/Defs-macosx.gmk	Wed Aug 15 14:35:36 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/jdk/make/common/shared/Defs-solaris.gmk	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/common/shared/Defs-solaris.gmk	Wed Aug 15 14:35:36 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/jdk/make/java/jli/Makefile	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/java/jli/Makefile	Wed Aug 15 14:35:36 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/jdk/make/java/zip/Makefile	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/java/zip/Makefile	Wed Aug 15 14:35:36 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/jdk/make/jdk_generic_profile.sh	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/jdk_generic_profile.sh	Wed Aug 15 14:35:36 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/jdk/make/sun/splashscreen/Makefile	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/make/sun/splashscreen/Makefile	Wed Aug 15 14:35:36 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/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h	Wed Aug 15 14:35:36 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/jdk/src/share/native/java/util/zip/Adler32.c	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/src/share/native/java/util/zip/Adler32.c	Wed Aug 15 14:35:36 2012 +0100
@@ -29,8 +29,8 @@
 
 #include "jni.h"
 #include "jni_util.h"
-#include "zlib.h"
 #include "jlong.h"
+#include <zlib.h>
 
 #include "java_util_zip_Adler32.h"
 
--- a/jdk/src/share/native/java/util/zip/CRC32.c	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/src/share/native/java/util/zip/CRC32.c	Wed Aug 15 14:35:36 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/jdk/src/share/native/java/util/zip/Deflater.c	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/src/share/native/java/util/zip/Deflater.c	Wed Aug 15 14:35:36 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/jdk/src/share/native/java/util/zip/Inflater.c	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/src/share/native/java/util/zip/Inflater.c	Wed Aug 15 14:35:36 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/jdk/src/share/native/java/util/zip/zip_util.c	Thu Aug 09 17:49:43 2012 +0200
+++ b/jdk/src/share/native/java/util/zip/zip_util.c	Wed Aug 15 14:35:36 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