changeset 4527:4a96e2fb4ca2

Support building using system libpng (USE_SYSTEM_PNG, PNG_CFLAGS, PNG_LIBS)
author andrew
date Thu, 04 Aug 2011 04:05:44 +0100
parents ad240835fa9c
children 353efa800ebe
files make/jdk_generic_profile.sh make/sun/splashscreen/FILES_c.gmk make/sun/splashscreen/Makefile src/share/native/sun/awt/splashscreen/splashscreen_png.c
diffstat 4 files changed, 50 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/make/jdk_generic_profile.sh	Wed Aug 03 23:29:24 2011 +0100
+++ b/make/jdk_generic_profile.sh	Thu Aug 04 04:05:44 2011 +0100
@@ -424,7 +424,26 @@
 fi
 export JPEG_LIBS
 
+# Export variables for system libpng
+# PNG_CFLAGS and PNG_LIBS tell the compiler how to compile and
+# link against libpng
+pkgconfig=$(which pkg-config 2>/dev/null)
+if [ -x "${pkgconfig}" ] ; then
+  if [ "${PNG_CFLAGS}" = "" ] ; then
+    PNG_CFLAGS=$("${pkgconfig}" --cflags libpng)
+  fi
+  if [ "${PNG_LIBS}" = "" ] ; then
+    PNG_LIBS=$("${pkgconfig}" --libs libpng)
+  fi
+fi
+if [ "${PNG_LIBS}" = "" ] ; then
+    PNG_LIBS="-lpng"
+fi
+export PNG_CFLAGS
+export PNG_LIBS
+
 # IcedTea defaults; use system libraries
 export USE_SYSTEM_LCMS=true
 export USE_SYSTEM_ZLIB=true
 export USE_SYSTEM_JPEG=true
+export USE_SYSTEM_PNG=true
--- a/make/sun/splashscreen/FILES_c.gmk	Wed Aug 03 23:29:24 2011 +0100
+++ b/make/sun/splashscreen/FILES_c.gmk	Thu Aug 04 04:05:44 2011 +0100
@@ -31,21 +31,6 @@
 	splashscreen_jpeg.c \
 	splashscreen_png.c \
 	splashscreen_sys.c \
-	png.c \
-	pngerror.c \
-	pngget.c \
-	pngmem.c  \
-	pngpread.c \
-	pngread.c \
-	pngrio.c \
-	pngrtran.c \
-	pngrutil.c \
-	pngset.c \
-	pngtrans.c \
-	pngwio.c \
-	pngwrite.c \
-	pngwtran.c \
-	pngwutil.c \
 	dgif_lib.c \
 	gif_err.c \
 	gifalloc.c
@@ -113,3 +98,22 @@
 	jfdctfst.c \
 	jfdctint.c
 endif
+
+ifndef USE_SYSTEM_PNG
+FILES_c += \
+	png.c \
+	pngerror.c \
+	pngget.c \
+	pngmem.c  \
+	pngpread.c \
+	pngread.c \
+	pngrio.c \
+	pngrtran.c \
+	pngrutil.c \
+	pngset.c \
+	pngtrans.c \
+	pngwio.c \
+	pngwrite.c \
+	pngwtran.c \
+	pngwutil.c
+endif
--- a/make/sun/splashscreen/Makefile	Wed Aug 03 23:29:24 2011 +0100
+++ b/make/sun/splashscreen/Makefile	Thu Aug 04 04:05:44 2011 +0100
@@ -71,6 +71,9 @@
   ifdef USE_SYSTEM_JPEG
     OTHER_LDLIBS += $(JPEG_LIBS)
   endif
+  ifdef USE_SYSTEM_PNG
+    OTHER_LDLIBS += $(PNG_LIBS)
+  endif
 else # PLATFORM
   CFLAGS += -DWITH_WIN32
   OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
@@ -86,7 +89,9 @@
 ifndef USE_SYSTEM_ZLIB
   vpath %.c   $(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
 endif
-vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/libpng
+ifndef USE_SYSTEM_PNG
+  vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/libpng
+endif
 ifndef USE_SYSTEM_JPEG
   vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/image/jpeg
 endif
@@ -101,6 +106,11 @@
 ifndef USE_SYSTEM_ZLIB
   CPPFLAGS += -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
 endif
+ifdef USE_SYSTEM_PNG
+  CPPFLAGS += $(PNG_CFLAGS)
+else
+  CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/libpng
+endif
 
 # Shun the less than portable MMX assembly code in pnggccrd.c,
 # and use alternative implementations in C.
--- a/src/share/native/sun/awt/splashscreen/splashscreen_png.c	Wed Aug 03 23:29:24 2011 +0100
+++ b/src/share/native/sun/awt/splashscreen/splashscreen_png.c	Thu Aug 04 04:05:44 2011 +0100
@@ -25,7 +25,7 @@
 
 #include "splashscreen_impl.h"
 
-#include "../libpng/png.h"
+#include <png.h>
 
 #include <setjmp.h>