Blame SOURCES/system-libjpeg.patch

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