Blame SOURCES/jdk8043805-allow_using_system_installed_libjpeg.patch

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