changeset 5825:d15095dfd348

System zlib fixes/improvements, rev. 2 Posted: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-August/011027.html
author andrew
date Fri, 03 Aug 2012 20:56:16 +0100
parents c80f9303eb60
children aa2c9ce06632
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	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/com/sun/java/pack/Makefile	Fri Aug 03 20:56:16 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/make/common/Program.gmk	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/common/Program.gmk	Fri Aug 03 20:56:16 2012 +0100
@@ -93,7 +93,7 @@
   LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
 
   ifeq ($(SYSTEM_ZLIB),true)
-    OTHER_LDLIBS += -lz
+    OTHER_LDLIBS += $(ZLIB_LIBS)
   endif
 endif
 
--- a/make/common/shared/Defs-linux.gmk	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/common/shared/Defs-linux.gmk	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/common/shared/Defs-macosx.gmk	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/common/shared/Defs-solaris.gmk	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/java/jli/Makefile	Fri Aug 03 20:56:16 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
 
@@ -157,7 +159,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	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/java/zip/Makefile	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/jdk_generic_profile.sh	Fri Aug 03 20:56:16 2012 +0100
@@ -380,6 +380,24 @@
   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
+
 # Export variables for system LCMS
 # LCMS_CFLAGS and LCMS_LIBS tell the compiler how to compile and
 # link against lcms2
@@ -400,3 +418,4 @@
 
 # IcedTea defaults; use system libraries
 export USE_SYSTEM_LCMS=true
+export SYSTEM_ZLIB=true
--- a/make/sun/splashscreen/Makefile	Fri Aug 03 20:23:18 2012 +0100
+++ b/make/sun/splashscreen/Makefile	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/src/share/native/com/sun/java/util/jar/pack/defines.h	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/src/share/native/java/util/zip/Adler32.c	Fri Aug 03 20:56:16 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/src/share/native/java/util/zip/CRC32.c	Fri Aug 03 20:23:18 2012 +0100
+++ b/src/share/native/java/util/zip/CRC32.c	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/src/share/native/java/util/zip/Deflater.c	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/src/share/native/java/util/zip/Inflater.c	Fri Aug 03 20:56:16 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	Fri Aug 03 20:23:18 2012 +0100
+++ b/src/share/native/java/util/zip/zip_util.c	Fri Aug 03 20:56:16 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