common/autoconf/libraries.m4
changeset 16424 d955df81d716
parent 15915 caa9b4e63aab
child 16581 b2cddec593f4
--- a/common/autoconf/libraries.m4	Tue Apr 02 13:59:30 2013 +0100
+++ b/common/autoconf/libraries.m4	Tue Apr 02 14:13:06 2013 -0400
@@ -499,11 +499,36 @@
 # 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_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
+
+AC_MSG_RESULT(${with_giflib})
+
+if test "x${with_giflib}" = "xbundled"; then
+    USE_EXTERNAL_LIBGIF=false
+elif test "x${with_giflib}" = "xsystem"; then
+    AC_CHECK_HEADER(gif_lib.h, [],
+             [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
+    AC_CHECK_LIB(gif, DGifGetCode, [],
+             [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
+
+    USE_EXTERNAL_LIBGIF=true
+else
+    AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
+fi
 AC_SUBST(USE_EXTERNAL_LIBGIF)
 
 ###############################################################################