Blame SOURCES/jdk8035341-allow_using_system_installed_libpng.patch

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