Blame SOURCES/jdk8043805-allow_using_system_installed_libjpeg.patch

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