Blame SOURCES/jdk8043805-allow_using_system_installed_libjpeg.patch

ecab97
diff -ruN jdk8/common/autoconf/libraries.m4 jdk8/common/autoconf/libraries.m4
ecab97
--- jdk8/common/autoconf/libraries.m4	2013-10-31 19:24:33.000000000 -0400
ecab97
+++ jdk8/common/autoconf/libraries.m4	2013-11-14 21:55:20.249903347 -0500
ecab97
@@ -601,12 +601,42 @@
ecab97
   #
ecab97
 
ecab97
   USE_EXTERNAL_LIBJPEG=true
ecab97
-  AC_CHECK_LIB(jpeg, main, [],
ecab97
-      [ USE_EXTERNAL_LIBJPEG=false
ecab97
-      AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
ecab97
-  ])
ecab97
+  AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg],
ecab97
+      [use libjpeg from build system or OpenJDK sources (system, bundled) @<:@bundled@:>@])])
ecab97
+
ecab97
+  AC_CHECK_LIB(jpeg, jpeg_destroy_compress,
ecab97
+               [ LIBJPEG_FOUND=yes ],
ecab97
+               [ LIBJPEG_FOUND=no ])
ecab97
+
ecab97
+  AC_MSG_CHECKING([for which libjpeg to use])
ecab97
+
ecab97
+  # default is bundled
ecab97
+  DEFAULT_LIBJPEG=bundled
ecab97
+
ecab97
+  #
ecab97
+  # if user didn't specify, use DEFAULT_LIBJPEG
ecab97
+  #
ecab97
+  if test "x${with_libjpeg}" = "x"; then
ecab97
+      with_libjpeg=${DEFAULT_LIBJPEG}
ecab97
+  fi
ecab97
+
ecab97
+  if test "x${with_libjpeg}" = "xbundled"; then
ecab97
+      USE_EXTERNAL_LIBJPEG=false
ecab97
+      AC_MSG_RESULT([bundled])
ecab97
+  elif test "x${with_libjpeg}" = "xsystem"; then
ecab97
+      if test "x${LIBJPEG_FOUND}" = "xyes"; then
ecab97
+          USE_EXTERNAL_LIBJPEG=true
ecab97
+          AC_MSG_RESULT([system])
ecab97
+      else
ecab97
+          AC_MSG_RESULT([system not found])
ecab97
+          AC_MSG_ERROR([--with-libjpeg=system specified, but no libjpeg found])
ecab97
+      fi
ecab97
+  else
ecab97
+      AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled'])
ecab97
+  fi
ecab97
   AC_SUBST(USE_EXTERNAL_LIBJPEG)
ecab97
 
ecab97
+
ecab97
   ###############################################################################
ecab97
   #
ecab97
   # Check for the gif library
ecab97
diff -ruN jdk8/jdk/make/lib/Awt2dLibraries.gmk jdk8/jdk/make/lib/Awt2dLibraries.gmk
ecab97
--- jdk8/jdk/make/lib/Awt2dLibraries.gmk	2013-10-31 19:44:18.000000000 -0400
ecab97
+++ jdk8/jdk/make/lib/Awt2dLibraries.gmk	2013-11-14 21:56:01.020796703 -0500
ecab97
@@ -693,17 +693,17 @@
ecab97
 ##########################################################################################
ecab97
 
ecab97
 ifdef OPENJDK
ecab97
-  BUILD_LIBJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers
ecab97
+  BUILD_LIBJAVAJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers
ecab97
 else
ecab97
-  BUILD_LIBJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers-closed
ecab97
-  BUILD_LIBJPEG_CLOSED_SRC := $(JDK_TOPDIR)/src/closed/share/native/sun/awt/image/jpeg
ecab97
-  BUILD_LIBJPEG_CLOSED_INCLUDES := -I$(BUILD_LIBJPEG_CLOSED_SRC)
ecab97
+  BUILD_LIBJAVAJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers-closed
ecab97
+  BUILD_LIBJAVAJPEG_CLOSED_SRC := $(JDK_TOPDIR)/src/closed/share/native/sun/awt/image/jpeg
ecab97
+  BUILD_LIBJAVAJPEG_CLOSED_INCLUDES := -I$(BUILD_LIBJPEG_CLOSED_SRC)
ecab97
 endif
ecab97
 
ecab97
-BUILD_LIBJPEG_REORDER :=
ecab97
+BUILD_LIBJAVAJPEG_REORDER :=
ecab97
 ifeq ($(OPENJDK_TARGET_OS), solaris)
ecab97
   ifneq ($(OPENJDK_TARGET_CPU), x86_64)
ecab97
-    BUILD_LIBJPEG_REORDER := $(JDK_TOPDIR)/make/mapfiles/libjpeg/reorder-$(OPENJDK_TARGET_CPU)
ecab97
+    BUILD_LIBJAVAJPEG_REORDER := $(JDK_TOPDIR)/make/mapfiles/libjpeg/reorder-$(OPENJDK_TARGET_CPU)
ecab97
   endif
ecab97
 endif
ecab97
 
ecab97
@@ -718,37 +718,38 @@
ecab97
 #      $(shell $(EXPR) $(CC_MAJORVER) \> 4 \| \
ecab97
 #          \( $(CC_MAJORVER) = 4 \& $(CC_MINORVER) \>= 3 \) )
ecab97
 #  ifeq ($(CC_43_OR_NEWER), 1)
ecab97
-#    BUILD_LIBJPEG_CFLAGS_linux += -Wno-clobbered
ecab97
+#    BUILD_LIBJAVAJPEG_CFLAGS_linux += -Wno-clobbered
ecab97
 #  endif
ecab97
 #endif
ecab97
 
ecab97
-$(eval $(call SetupNativeCompilation,BUILD_LIBJPEG, \
ecab97
-    LIBRARY := jpeg, \
ecab97
+$(eval $(call SetupNativeCompilation,BUILD_LIBJAVAJPEG, \
ecab97
+    LIBRARY := javajpeg, \
ecab97
     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
ecab97
-    SRC := $(BUILD_LIBJPEG_CLOSED_SRC) \
ecab97
+    SRC := $(BUILD_LIBJAVAJPEG_CLOSED_SRC) \
ecab97
         $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg, \
ecab97
     LANG := C, \
ecab97
     OPTIMIZATION := HIGHEST, \
ecab97
     CFLAGS := $(CFLAGS_JDKLIB) \
ecab97
-        $(BUILD_LIBJPEG_CLOSED_INCLUDES) \
ecab97
+        $(BUILD_LIBJAVAJPEG_CLOSED_INCLUDES) \
ecab97
         -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg, \
ecab97
-    MAPFILE := $(BUILD_LIBJPEG_MAPFILE), \
ecab97
-    LDFLAGS := $(LDFLAGS_JDKLIB) \
ecab97
+    MAPFILE := $(BUILD_LIBJAVAJPEG_MAPFILE), \
ecab97
+    LDFLAGS := $(subst -Xlinker --as-needed,, \
ecab97
+        $(subst -Wl$(COMMA)--as-needed,, $(LDFLAGS_JDKLIB))) -ljpeg \
ecab97
         $(call SET_SHARED_LIBRARY_ORIGIN), \
ecab97
     LDFLAGS_windows := $(WIN_JAVA_LIB) jvm.lib, \
ecab97
     LDFLAGS_SUFFIX := $(LDFLAGS_JDKLIB_SUFFIX), \
ecab97
     VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
ecab97
     RC_FLAGS := $(RC_FLAGS) \
ecab97
-        -D "JDK_FNAME=jpeg.dll" \
ecab97
-        -D "JDK_INTERNAL_NAME=jpeg" \
ecab97
+        -D "JDK_FNAME=javajpeg.dll" \
ecab97
+        -D "JDK_INTERNAL_NAME=javajpeg" \
ecab97
         -D "JDK_FTYPE=0x2L", \
ecab97
-    REORDER := $(BUILD_LIBJPEG_REORDER), \
ecab97
-    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjpeg, \
ecab97
+    REORDER := $(BUILD_LIBJAVAJPEG_REORDER), \
ecab97
+    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjavajpeg, \
ecab97
     DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
ecab97
 
ecab97
-$(BUILD_LIBJPEG): $(BUILD_LIBJAVA)
ecab97
+$(BUILD_LIBJAVAJPEG): $(BUILD_LIBJAVA)
ecab97
 
ecab97
-BUILD_LIBRARIES += $(BUILD_LIBJPEG)
ecab97
+BUILD_LIBRARIES += $(BUILD_LIBJAVAJPEG)
ecab97
 
ecab97
 ##########################################################################################
ecab97
 
ecab97
@@ -1127,7 +1128,6 @@
ecab97
 
ecab97
 ifndef BUILD_HEADLESS_ONLY
ecab97
   LIBSPLASHSCREEN_DIRS := \
ecab97
-    $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \
ecab97
     $(JDK_TOPDIR)/src/share/native/sun/awt/libpng \
ecab97
     $(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen
ecab97
 
ecab97
@@ -1138,6 +1138,13 @@
ecab97
     GIFLIB_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/giflib
ecab97
   endif
ecab97
 
ecab97
+  ifeq ($(USE_EXTERNAL_LIBJPEG), true)
ecab97
+    LIBJPEG_LDFLAGS := -ljpeg
ecab97
+  else
ecab97
+    LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg
ecab97
+    LIBJPEG_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/jpeg
ecab97
+  endif
ecab97
+
ecab97
   ifneq ($(OPENJDK_TARGET_OS), macosx)
ecab97
     LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/splashscreen
ecab97
   else
ecab97
@@ -1193,11 +1200,13 @@
ecab97
       EXCLUDE_FILES := imageioJPEG.c jpegdecoder.c pngtest.c, \
ecab97
       LANG := C, \
ecab97
       OPTIMIZATION := LOW, \
ecab97
-      CFLAGS := $(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) $(GIFLIB_CFLAGS), \
ecab97
+      CFLAGS := $(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) \
ecab97
+          $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS), \
ecab97
       MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libsplashscreen/mapfile-vers, \
ecab97
       LDFLAGS := $(LDFLAGS_JDKLIB) \
ecab97
           $(call SET_SHARED_LIBRARY_ORIGIN), \
ecab97
-      LDFLAGS_SUFFIX := $(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ) $(GIFLIB_LDFLAGS), \
ecab97
+      LDFLAGS_SUFFIX := $(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) \
ecab97
+          $(LIBZ) $(GIFLIB_LDFLAGS) $(LIBJPEG_LDFLAGS), \
ecab97
       LDFLAGS_SUFFIX_solaris := -lc, \
ecab97
       VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
ecab97
       RC_FLAGS := $(RC_FLAGS) \
ecab97
diff -ruN jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
ecab97
--- jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	2013-10-31 19:44:18.000000000 -0400
ecab97
+++ jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	2013-11-14 21:55:20.250903340 -0500
ecab97
@@ -89,7 +89,7 @@
ecab97
         java.security.AccessController.doPrivileged(
ecab97
             new java.security.PrivilegedAction<Void>() {
ecab97
                 public Void run() {
ecab97
-                    System.loadLibrary("jpeg");
ecab97
+                    System.loadLibrary("javajpeg");
ecab97
                     return null;
ecab97
                 }
ecab97
             });
ecab97
diff -ruN jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
ecab97
--- jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java	2013-10-31 19:44:18.000000000 -0400
ecab97
+++ jdk8/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java	2013-11-14 21:55:20.250903340 -0500
ecab97
@@ -179,7 +179,7 @@
ecab97
         java.security.AccessController.doPrivileged(
ecab97
             new java.security.PrivilegedAction<Void>() {
ecab97
                 public Void run() {
ecab97
-                    System.loadLibrary("jpeg");
ecab97
+                    System.loadLibrary("javajpeg");
ecab97
                     return null;
ecab97
                 }
ecab97
             });
ecab97
diff -ruN jdk8/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java jdk8/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java
ecab97
--- jdk8/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java	2013-10-31 19:44:18.000000000 -0400
ecab97
+++ jdk8/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java	2013-11-14 21:55:20.251903376 -0500
ecab97
@@ -56,7 +56,7 @@
ecab97
         java.security.AccessController.doPrivileged(
ecab97
             new java.security.PrivilegedAction<Void>() {
ecab97
                 public Void run() {
ecab97
-                    System.loadLibrary("jpeg");
ecab97
+                    System.loadLibrary("javajpeg");
ecab97
                     return null;
ecab97
                 }
ecab97
             });
ecab97
diff -ruN jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_jpeg.c jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_jpeg.c
ecab97
--- jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_jpeg.c	2013-10-31 19:44:18.000000000 -0400
ecab97
+++ jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_jpeg.c	2013-11-14 21:55:20.251903376 -0500
ecab97
@@ -25,7 +25,6 @@
ecab97
 
ecab97
 #include "splashscreen_impl.h"
ecab97
 
ecab97
-#include "jinclude.h"
ecab97
 #include "jpeglib.h"
ecab97
 #include "jerror.h"
ecab97
 
ecab97
@@ -107,11 +106,11 @@
ecab97
     if (cinfo->src == NULL) {   /* first time for this JPEG object? */
ecab97
         cinfo->src = (struct jpeg_source_mgr *)
ecab97
             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
ecab97
-            JPOOL_PERMANENT, SIZEOF(stream_source_mgr));
ecab97
+            JPOOL_PERMANENT, sizeof(stream_source_mgr));
ecab97
         src = (stream_src_ptr) cinfo->src;
ecab97
         src->buffer = (JOCTET *)
ecab97
             (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
ecab97
-            JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
ecab97
+            JPOOL_PERMANENT, INPUT_BUF_SIZE * sizeof(JOCTET));
ecab97
     }
ecab97
 
ecab97
     src = (stream_src_ptr) cinfo->src;