Blame SOURCES/jdk8043805-allow_using_system_installed_libjpeg.patch

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