Blame SOURCES/jdk8043805-allow_using_system_installed_libjpeg.patch

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