Blame SOURCES/system-libjpeg.patch

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