Blame SOURCES/jdk8042159-allow_using_system_installed_lcms2.patch

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