Blame SOURCES/jdk8043805-allow_using_system_installed_libjpeg.patch

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