--- old/common/autoconf/libraries.m4 2013-03-07 21:02:01.418752684 -0500 +++ new/common/autoconf/libraries.m4 2013-03-07 21:02:01.225750884 -0500 @@ -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) ###############################################################################