diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 --- jdk8/common/autoconf/libraries.m4 +++ jdk8/common/autoconf/libraries.m4 @@ -499,11 +499,40 @@ # Check for the gif library # -USE_EXTERNAL_LIBJPEG=true -AC_CHECK_LIB(gif, main, [], - [ USE_EXTERNAL_LIBGIF=false - AC_MSG_NOTICE([Will use gif decoder bundled with the OpenJDK source]) - ]) +AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib], + [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) + +AC_CHECK_LIB(gif, DGifGetCode, + [ GIFLIB_FOUND=yes ], + [ GIFLIB_FOUND=no ]) + +AC_MSG_CHECKING([for which giflib to use]) + +# default is bundled +DEFAULT_GIFLIB=bundled + +# +# if user didn't specify, use DEFAULT_GIFLIB +# +if test "x${with_giflib}" = "x"; then + with_giflib=${DEFAULT_GIFLIB} +fi + + +if test "x${with_giflib}" = "xbundled"; then + USE_EXTERNAL_LIBGIF=false + AC_MSG_RESULT([bundled]) +elif test "x${with_giflib}" = "xsystem"; then + if test "x${GIFLIB_FOUND}" = "xyes"; then + USE_EXTERNAL_LIBGIF=true + AC_MSG_RESULT([system]) + else + AC_MSG_RESULT([system not found]) + AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!]) + fi +else + AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled']) +fi AC_SUBST(USE_EXTERNAL_LIBGIF) ############################################################################### diff --git a/makefiles/CompileNativeLibraries.gmk b/makefiles/CompileNativeLibraries.gmk --- jdk8/jdk/makefiles/CompileNativeLibraries.gmk +++ jdk8/jdk/makefiles/CompileNativeLibraries.gmk @@ -2385,18 +2385,23 @@ ifndef BUILD_HEADLESS_ONLY LIBSPLASHSCREEN_DIRS:=\ - $(JDK_TOPDIR)/src/share/native/sun/awt/giflib \ $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \ $(JDK_TOPDIR)/src/share/native/sun/awt/libpng \ $(JDK_TOPDIR)/src/share/native/sun/awt/splashscreen +ifeq ($(USE_EXTERNAL_LIBGIF),true) + LIBGIF := -lgif +else + LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/share/native/sun/awt/giflib + LIBGIF_CFLAGS := -I$(JDK_TOPDIR)/src/share/native/sun/awt/giflib +endif + ifneq ($(OPENJDK_TARGET_OS), macosx) LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/awt/splashscreen else LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/awt/splashscreen endif - LIBSPLASHSCREEN_CFLAGS:=-DSPLASHSCREEN -DPNG_NO_MMX_CODE \ $(foreach dir,$(LIBSPLASHSCREEN_DIRS),-I$(dir)) @@ -2448,11 +2453,11 @@ EXCLUDE_FILES:=imageioJPEG.c jpegdecoder.c pngtest.c,\ LANG:=C,\ OPTIMIZATION:=LOW, \ - CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB),\ + CFLAGS:=$(LIBSPLASHSCREEN_CFLAGS) $(CFLAGS_JDKLIB) -I$(LIBGIF_CFLAGS),\ MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libsplashscreen/mapfile-vers, \ LDFLAGS:=$(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN),\ - LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ),\ + LDFLAGS_SUFFIX:=$(LIBSPLASHSCREEN_LDFLAGS_SUFFIX) $(LIBZ) $(LIBGIF),\ LDFLAGS_SUFFIX_solaris:=-lc,\ VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\ RC_FLAGS:=$(RC_FLAGS)\ diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_gif.c b/src/share/native/sun/awt/splashscreen/splashscreen_gif.c --- jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c +++ jdk8/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c @@ -26,7 +26,7 @@ #include "splashscreen_impl.h" #include "splashscreen_gfx.h" -#include "../giflib/gif_lib.h" +#include "gif_lib.h" #define GIF_TRANSPARENT 0x01 #define GIF_USER_INPUT 0x02