Blame SOURCES/jdk8042159-allow_using_system_installed_lcms2.patch

2d54fe
diff -ruN jdk8/common/autoconf/libraries.m4 jdk8/common/autoconf/libraries.m4
2d54fe
--- openjdk/common/autoconf/libraries.m4	2013-11-14 22:04:38.039440136 -0500
2d54fe
+++ openjdk/common/autoconf/libraries.m4	2013-11-14 22:05:11.474356424 -0500
2d54fe
@@ -676,6 +676,46 @@
2d54fe
 
2d54fe
   ###############################################################################
2d54fe
   #
2d54fe
+  # Check for the lcms2 library
2d54fe
+  #
2d54fe
+
2d54fe
+  AC_ARG_WITH(lcms, [AS_HELP_STRING([--with-lcms],
2d54fe
+  	[use lcms2 from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
2d54fe
+
2d54fe
+  AC_CHECK_LIB(lcms2, cmsOpenProfileFromFile,
2d54fe
+               [ LCMS_FOUND=yes ],
2d54fe
+               [ LCMS_FOUND=no ])
2d54fe
+
2d54fe
+  AC_MSG_CHECKING([for which lcms to use])
2d54fe
+
2d54fe
+  DEFAULT_LCMS=bundled
2d54fe
+
2d54fe
+  #
2d54fe
+  # If user didn't specify, use DEFAULT_LCMS
2d54fe
+  #
2d54fe
+  if test "x${with_lcms}" = "x"; then
2d54fe
+      with_lcms=${DEFAULT_LCMS}
2d54fe
+  fi
2d54fe
+
2d54fe
+  if test "x${with_lcms}" = "xbundled"; then
2d54fe
+      USE_EXTERNAL_LCMS=false
2d54fe
+      AC_MSG_RESULT([bundled])
2d54fe
+  elif test "x${with_lcms}" = "xsystem"; then
2d54fe
+      if test "x${LCMS_FOUND}" = "xyes"; then
2d54fe
+          USE_EXTERNAL_LCMS=true
2d54fe
+          AC_MSG_RESULT([system])
2d54fe
+      else
2d54fe
+          AC_MSG_RESULT([system not found])
2d54fe
+          AC_MSG_ERROR([--with-lcms=system specified, but no lcms found!])
2d54fe
+      fi
2d54fe
+  else
2d54fe
+      AC_MSG_ERROR([Invalid value for --with-lcms: ${with_lcms}, use 'system' or 'bundled'])
2d54fe
+  fi
2d54fe
+
2d54fe
+  AC_SUBST(USE_EXTERNAL_LCMS)
2d54fe
+
2d54fe
+  ###############################################################################
2d54fe
+  #
2d54fe
   # Check for the png library
2d54fe
   #
2d54fe
 
2d54fe
diff -ruN jdk8/jdk/make/lib/Awt2dLibraries.gmk jdk8/jdk/make/lib/Awt2dLibraries.gmk
2d54fe
--- openjdk/jdk/make/lib/Awt2dLibraries.gmk	2013-11-14 22:04:38.040440133 -0500
2d54fe
+++ openjdk/jdk/make/lib/Awt2dLibraries.gmk	2013-11-14 22:05:11.475356411 -0500
2d54fe
@@ -666,18 +666,35 @@
2d54fe
 
2d54fe
 ##########################################################################################
2d54fe
 
2d54fe
+LIBLCMS_DIR := $(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms
2d54fe
+
2d54fe
+ifeq ($(USE_EXTERNAL_LCMS), true)
2d54fe
+  # If we're using an external library, we'll just need the wrapper part.
2d54fe
+  # By including it explicitely, all other files will be excluded.
2d54fe
+  BUILD_LIBLCMS_INCLUDE_FILES := LCMS.c
2d54fe
+  BUILD_LIBLCMS_HEADERS :=
2d54fe
+else
2d54fe
+  BUILD_LIBLCMS_INCLUDE_FILES :=
2d54fe
+  # If we're using the bundled library, we'll need to include it in the
2d54fe
+  # include path explicitly. Otherwise the system headers will be used.
2d54fe
+  BUILD_LIBLCMS_HEADERS := -I$(LIBLCMS_DIR)
2d54fe
+endif
2d54fe
+
2d54fe
 # TODO: Update awt lib path when awt is converted
2d54fe
 $(eval $(call SetupNativeCompilation,BUILD_LIBLCMS, \
2d54fe
     LIBRARY := lcms, \
2d54fe
     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
2d54fe
-    SRC := $(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms, \
2d54fe
+    SRC := $(LIBLCMS_DIR), \
2d54fe
+    INCLUDE_FILES := $(BUILD_LIBLCMS_INCLUDE_FILES), \
2d54fe
     LANG := C, \
2d54fe
     OPTIMIZATION := HIGHEST, \
2d54fe
     CFLAGS := $(filter-out -xc99=%none, $(CFLAGS_JDKLIB)) \
2d54fe
         -DCMS_DONT_USE_FAST_FLOOR \
2d54fe
         $(SHARED_LIBRARY_FLAGS) \
2d54fe
         -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
2d54fe
-        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug, \
2d54fe
+        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
2d54fe
+        $(BUILD_LIBLCMS_HEADERS) \
2d54fe
+        $(LCMS_CFLAGS), \
2d54fe
     CFLAGS_solaris := -xc99=no_lib, \
2d54fe
     CFLAGS_windows := -DCMS_IS_WINDOWS_, \
2d54fe
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/liblcms/mapfile-vers, \
2d54fe
@@ -685,10 +702,10 @@
2d54fe
         $(call SET_SHARED_LIBRARY_ORIGIN), \
2d54fe
     LDFLAGS_solaris := /usr/lib$(OPENJDK_TARGET_CPU_ISADIR)/libm.so.2, \
2d54fe
     LDFLAGS_windows := $(WIN_AWT_LIB) $(WIN_JAVA_LIB), \
2d54fe
-    LDFLAGS_SUFFIX_solaris := -lawt -ljava -ljvm -lc, \
2d54fe
-    LDFLAGS_SUFFIX_macosx := $(LIBM) -lawt -ljava -ljvm, \
2d54fe
-    LDFLAGS_SUFFIX_linux := -lm -lawt -ljava -ljvm, \
2d54fe
-    LDFLAGS_SUFFIX_aix := -lm -lawt -ljava -ljvm,\
2d54fe
+    LDFLAGS_SUFFIX_solaris := -lawt -ljava -ljvm -lc $(LCMS_LIBS), \
2d54fe
+    LDFLAGS_SUFFIX_macosx := $(LIBM) -lawt -ljava -ljvm $(LCMS_LIBS), \
2d54fe
+    LDFLAGS_SUFFIX_linux := -lm -lawt -ljava -ljvm $(LCMS_LIBS), \
2d54fe
+    LDFLAGS_SUFFIX_aix := -lm -lawt -ljava -ljvm $(LCMS_LIBS),\
2d54fe
     VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
2d54fe
     RC_FLAGS := $(RC_FLAGS) \
2d54fe
         -D "JDK_FNAME=lcms.dll" \
2d54fe
diff -r 3d1c3b0b73a3 src/share/native/sun/java2d/cmm/lcms/LCMS.c
2d54fe
--- openjdk/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c	Tue Sep 08 22:31:26 2015 +0300
2d54fe
+++ openjdk/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c	Thu Oct 15 05:29:28 2015 +0100
2d54fe
@@ -30,7 +30,7 @@
2d54fe
 #include "jni_util.h"
2d54fe
 #include "Trace.h"
2d54fe
 #include "Disposer.h"
2d54fe
-#include "lcms2.h"
2d54fe
+#include <lcms2.h>
2d54fe
 #include "jlong.h"
2d54fe
 
2d54fe