diff --git a/make/com/sun/java/pack/Makefile b/make/com/sun/java/pack/Makefile index e97ac51954e9b84c1669293eaaf5e5d687bea736..0530d37c8d8c8a081d828bb19a051f1e626573ac 100644 --- a/make/com/sun/java/pack/Makefile +++ b/make/com/sun/java/pack/Makefile @@ -77,8 +77,8 @@ ifeq ($(STANDALONE),true) 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 diff --git a/make/common/Program.gmk b/make/common/Program.gmk index 89765d02fc023dd4e3302d56b16f7fea5986fb3f..0ad45e5331ebce74170cf0348f94dcc0dfac624a 100644 --- a/make/common/Program.gmk +++ b/make/common/Program.gmk @@ -91,7 +91,7 @@ ifeq ($(PLATFORM), macosx) LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a ifeq ($(SYSTEM_ZLIB),true) - OTHER_LDLIBS += -lz + OTHER_LDLIBS += $(ZLIB_LIBS) endif endif diff --git a/make/common/shared/Defs-linux.gmk b/make/common/shared/Defs-linux.gmk index ecdf5d77ee4d57b05fd831dabf26a9879d54e94c..32388050d42ec6722c290e1ef7070f9d5c406f99 100644 --- a/make/common/shared/Defs-linux.gmk +++ b/make/common/shared/Defs-linux.gmk @@ -129,6 +129,11 @@ endif 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 diff --git a/make/common/shared/Defs-macosx.gmk b/make/common/shared/Defs-macosx.gmk index b9662965b69db9cc0652076e483cc07b4b755b8b..1bd9b92b5f140df99454ca06304df601126abd7c 100644 --- a/make/common/shared/Defs-macosx.gmk +++ b/make/common/shared/Defs-macosx.gmk @@ -143,6 +143,11 @@ else _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. diff --git a/make/common/shared/Defs-solaris.gmk b/make/common/shared/Defs-solaris.gmk index 261583d9af97413db8823c9935d7d27622c94366..ec1dd148f131f5b857b0d4d258c83ae7874ffdc6 100644 --- a/make/common/shared/Defs-solaris.gmk +++ b/make/common/shared/Defs-solaris.gmk @@ -140,6 +140,11 @@ BUILD_HEADLESS = true _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. diff --git a/make/java/jli/Makefile b/make/java/jli/Makefile index e9fbaa0c159b66ab787bc9cf218d7ebff8669c92..eebd88c0695c163e6ce0cf975d6697c9487120c9 100644 --- a/make/java/jli/Makefile +++ b/make/java/jli/Makefile @@ -46,6 +46,8 @@ include $(BUILDDIR)/common/Defs.gmk 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 @@ OTHER_INCLUDES += -I$(LAUNCHER_PLATFORM_SRC) ifneq ($(SYSTEM_ZLIB),true) OTHER_INCLUDES += -I$(ZIP_SRC) else # !SYSTEM_ZLIB - LDLIBS += -lz + LDLIBS += $(ZLIB_LIBS) endif # SYSTEM_ZLIB # diff --git a/make/java/zip/Makefile b/make/java/zip/Makefile index 5955335821539158a0fd87687d63b7c5df992fd7..e1d3c5b7e594a92874d6f4a9b4a27cc93d2d769b 100644 --- a/make/java/zip/Makefile +++ b/make/java/zip/Makefile @@ -56,6 +56,10 @@ ifneq ($(PLATFORM), windows) endif endif +ifeq ($(SYSTEM_ZLIB),true) + OTHER_CFLAGS += $(ZLIB_CFLAGS) +endif + # # Library to compile. # @@ -90,7 +94,7 @@ endif # Link to JVM library for JVM_Zip* functions # ifeq ($(SYSTEM_ZLIB),true) -OTHER_LDLIBS = -lz +OTHER_LDLIBS = $(ZLIB_LIBS) else OTHER_LDLIBS = $(JVMLIB) endif diff --git a/make/jdk_generic_profile.sh b/make/jdk_generic_profile.sh index 0190fc6bc2476ca4cb5e05c6d18c159c222f0de1..93aa1cd4d25e83e64a74433dcca7a4b6f4dfe0dc 100644 --- a/make/jdk_generic_profile.sh +++ b/make/jdk_generic_profile.sh @@ -378,3 +378,22 @@ if [ "${ZERO_BUILD}" = true ] ; then 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 + diff --git a/make/sun/splashscreen/Makefile b/make/sun/splashscreen/Makefile index 5b0e18afaa10cc563145d64b11813d233245c8d2..1eb89e5eb8c6a0120d44013e850e69c58528921e 100644 --- a/make/sun/splashscreen/Makefile +++ b/make/sun/splashscreen/Makefile @@ -126,7 +126,8 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg 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, diff --git a/src/share/native/com/sun/java/util/jar/pack/defines.h b/src/share/native/com/sun/java/util/jar/pack/defines.h index 7fe36ffe5760a1565ade008e42cbd75812a83ede..b202892fa7e7920e9d52c507a7a49da846fd4dbf 100644 --- a/src/share/native/com/sun/java/util/jar/pack/defines.h +++ b/src/share/native/com/sun/java/util/jar/pack/defines.h @@ -93,7 +93,7 @@ extern int assert_failed(const char*); // 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 diff --git a/src/share/native/java/util/zip/Adler32.c b/src/share/native/java/util/zip/Adler32.c index 36b5499e28b5daa6e1ec5469b280fd01fa8ecc36..76003933699b2ed860e507a3fdc1275942a21c1c 100644 --- a/src/share/native/java/util/zip/Adler32.c +++ b/src/share/native/java/util/zip/Adler32.c @@ -29,8 +29,8 @@ #include "jni.h" #include "jni_util.h" -#include "zlib.h" #include "jlong.h" +#include #include "java_util_zip_Adler32.h" diff --git a/src/share/native/java/util/zip/CRC32.c b/src/share/native/java/util/zip/CRC32.c index c8cb2dea9835d6b802d9b14b2423fd92787f45b9..e04c251c39270934521135910e9413ba9de09007 100644 --- a/src/share/native/java/util/zip/CRC32.c +++ b/src/share/native/java/util/zip/CRC32.c @@ -29,7 +29,7 @@ #include "jni.h" #include "jni_util.h" -#include "zlib.h" +#include #include "java_util_zip_CRC32.h" diff --git a/src/share/native/java/util/zip/Deflater.c b/src/share/native/java/util/zip/Deflater.c index 3977af4684cf67b69cb835428a0a291e8c4b3d31..dbf5ea448578f60337202a889142c8fd9cd8613d 100644 --- a/src/share/native/java/util/zip/Deflater.c +++ b/src/share/native/java/util/zip/Deflater.c @@ -32,7 +32,7 @@ #include "jlong.h" #include "jni.h" #include "jni_util.h" -#include "zlib.h" +#include #include "java_util_zip_Deflater.h" diff --git a/src/share/native/java/util/zip/Inflater.c b/src/share/native/java/util/zip/Inflater.c index 837baef75ed5a4dd709edca0b97c1cc03a1ff387..062a89230bd9371d9ed50520842534f909364eca 100644 --- a/src/share/native/java/util/zip/Inflater.c +++ b/src/share/native/java/util/zip/Inflater.c @@ -35,7 +35,7 @@ #include "jni.h" #include "jvm.h" #include "jni_util.h" -#include "zlib.h" +#include #include "java_util_zip_Inflater.h" #define ThrowDataFormatException(env, msg) \ diff --git a/src/share/native/java/util/zip/zip_util.c b/src/share/native/java/util/zip/zip_util.c index 9bffd3461e5be57ff48d20b9a764d4e3deac30d9..f46676ddeecda29471564b2c38e332af7d654db4 100644 --- a/src/share/native/java/util/zip/zip_util.c +++ b/src/share/native/java/util/zip/zip_util.c @@ -44,7 +44,7 @@ #include "io_util.h" #include "io_util_md.h" #include "zip_util.h" -#include "zlib.h" +#include #ifdef _ALLBSD_SOURCE #define off64_t off_t