Blame SOURCES/jdk8035341-allow_using_system_installed_libpng.patch

2d54fe
diff -ruN jdk8/common/autoconf/libraries.m4 jdk8/common/autoconf/libraries.m4
2d54fe
--- jdk8/common/autoconf/libraries.m4	2013-11-14 20:08:01.845065585 -0500
2d54fe
+++ jdk8/common/autoconf/libraries.m4	2013-11-14 20:10:56.186553066 -0500
2d54fe
@@ -676,6 +676,47 @@
2d54fe
 
2d54fe
   ###############################################################################
2d54fe
   #
2d54fe
+  # Check for the png library
2d54fe
+  #
2d54fe
+
2d54fe
+  AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng],
2d54fe
+     [use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
2d54fe
+
2d54fe
+  AC_CHECK_LIB(png, png_sig_cmp,
2d54fe
+               [ LIBPNG_FOUND=yes ],
2d54fe
+               [ LIBPNG_FOUND=no ])
2d54fe
+
2d54fe
+  AC_MSG_CHECKING([for which libpng to use])
2d54fe
+
2d54fe
+  # default is bundled
2d54fe
+  DEFAULT_LIBPNG=bundled
2d54fe
+
2d54fe
+  #
2d54fe
+  # if user didn't specify, use DEFAULT_LIBPNG
2d54fe
+  #
2d54fe
+  if test "x${with_libpng}" = "x"; then
2d54fe
+      with_libpng=${DEFAULT_libpng}
2d54fe
+  fi
2d54fe
+
2d54fe
+
2d54fe
+  if test "x${with_libpng}" = "xbundled"; then
2d54fe
+      USE_EXTERNAL_LIBPNG=false
2d54fe
+      AC_MSG_RESULT([bundled])
2d54fe
+  elif test "x${with_libpng}" = "xsystem"; then
2d54fe
+      if test "x${LIBPNG_FOUND}" = "xyes"; then
2d54fe
+          USE_EXTERNAL_LIBPNG=true
2d54fe
+          AC_MSG_RESULT([system])
2d54fe
+      else
2d54fe
+          AC_MSG_RESULT([system not found])
2d54fe
+          AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!])
2d54fe
+      fi
2d54fe
+  else
2d54fe
+      AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled'])
2d54fe
+  fi
2d54fe
+  AC_SUBST(USE_EXTERNAL_LIBPNG)
2d54fe
+
2d54fe
+  ###############################################################################
2d54fe
+  #
2d54fe
   # Check for the zlib library
2d54fe
   #
2d54fe
 
2d54fe
diff -ruN jdk8/common/autoconf/spec.gmk.in jdk8/common/autoconf/spec.gmk.in
2d54fe
--- jdk8/common/autoconf/spec.gmk.in	2013-10-31 19:24:33.000000000 -0400
2d54fe
+++ jdk8/common/autoconf/spec.gmk.in	2013-11-14 21:10:56.365976518 -0500
2d54fe
@@ -548,6 +548,7 @@
2d54fe
 ENABLE_JFR=@ENABLE_JFR@
2d54fe
 ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
2d54fe
 USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@
2d54fe
+USE_EXTERNAL_LIBPNG:=@USE_EXTERNAL_LIBPNG@
2d54fe
 USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@
2d54fe
 USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@
2d54fe
 LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@
2d54fe
diff -ruN jdk8/jdk/make/lib/Awt2dLibraries.gmk jdk8/jdk/make/lib/Awt2dLibraries.gmk
2d54fe
--- jdk8/jdk/make/lib/Awt2dLibraries.gmk	2013-11-14 20:08:01.845065585 -0500
2d54fe
+++ jdk8/jdk/make/lib/Awt2dLibraries.gmk	2013-11-14 20:14:10.791982343 -0500
2d54fe
@@ -1183,7 +1183,6 @@
2d54fe
 
2d54fe
 ifndef BUILD_HEADLESS_ONLY
2d54fe
   LIBSPLASHSCREEN_DIRS := \
2d54fe
-    $(JDK_TOPDIR)/src/share/native/sun/awt/libpng \
2d54fe
     $(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen
2d54fe
 
2d54fe
   ifeq ($(USE_EXTERNAL_LIBGIF), true)
2d54fe
@@ -1200,6 +1199,13 @@
2d54fe
     LIBJPEG_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/jpeg
2d54fe
   endif
2d54fe
 
2d54fe
+  ifeq ($(USE_EXTERNAL_LIBPNG), true)
2d54fe
+    LIBPNG_LDFLAGS := -lpng
2d54fe
+  else
2d54fe
+    LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/sun/awt/image/libpng
2d54fe
+    LIBPNG_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/libpng
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
@@ -1263,12 +1269,12 @@
2d54fe
       LANG := C, \
2d54fe
       OPTIMIZATION := LOW, \
2d54fe
       CFLAGS := $(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) \
2d54fe
-          $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS), \
2d54fe
+          $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS) $(LIBPNG_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) \
2d54fe
-          $(LIBZ) $(GIFLIB_LDFLAGS) $(LIBJPEG_LDFLAGS), \
2d54fe
+          $(LIBZ) $(GIFLIB_LDFLAGS) $(LIBJPEG_LDFLAGS) $(LIBPNG_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/native/sun/awt/splashscreen/splashscreen_png.c jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_png.c
2d54fe
--- jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_png.c	2013-10-31 19:44:18.000000000 -0400
2d54fe
+++ jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_png.c	2013-11-14 20:14:41.363892797 -0500
2d54fe
@@ -25,8 +25,7 @@
2d54fe
 
2d54fe
 #include "splashscreen_impl.h"
2d54fe
 
2d54fe
-#include "../libpng/png.h"
2d54fe
-
2d54fe
+#include <png.h>
2d54fe
 #include <setjmp.h>
2d54fe
 
2d54fe
 #define SIG_BYTES 8