+###############################################################################
+#
+# Check for -lgdk_pixbuf.
+#
+###############################################################################
+
+have_gdk_pixbuf=no
+with_gdk_pixbuf_req=unspecified
+AC_ARG_WITH(pixbuf,
+[ --with-pixbuf Include support for the GDK-Pixbuf library in some
+ demos, which will make it possible for them to read
+ GIF, JPEG, and PNG files as well.],
+ [with_gdk_pixbuf="$withval"; with_gdk_pixbuf_req="$withval"],
+ [with_gdk_pixbuf=yes])
+
+# if --with-pixbuf=/directory/ was specified, remember that directory so that
+# we can also look for the `gdk-pixbuf-config' program in that directory.
+case "$with_gdk_pixbuf" in
+ /*)
+ gdk_pixbuf_dir="$with_gdk_pixbuf"
+ ;;
+ *)
+ gdk_pixbuf_dir=""
+ ;;
+esac
+
+HANDLE_X_PATH_ARG(with_gdk_pixbuf, --with-pixbuf, GDK_PIXBUF)
+
+if test "$with_gdk_pixbuf" != yes -a "$with_gdk_pixbuf" != no ; then
+ echo "error: must be yes or no: --with-pixbuf=$with_gdk_pixbuf"
+ exit 1
+fi
+
+if test "$with_gdk_pixbuf" = yes; then
+ have_gdk_pixbuf=no
+
+ # if the user specified --with-gtk=/foo/ or --with-gnome=/foo/ then
+ # look in /foo/bin/ for for gdk-pixbuf-config.
+ #
+ gdk_pixbuf_path="$PATH"
+
+ if test ! -z "$gtk_dir"; then
+ # canonicalize slashes.
+ foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
+ gdk_pixbuf_path="$foo:$gdk_pixbuf_path"
+ fi
+
+ if test ! -z "$gnome_dir"; then
+ # canonicalize slashes.
+ foo=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
+ gdk_pixbuf_path="$foo:$gdk_pixbuf_path"
+ fi
+
+ AC_PATH_PROGS(gdk_pixbuf_config, gdk-pixbuf-config,, $gdk_pixbuf_path)
+
+ # If we found the gdk-pixbuf-config program, run it to get flags.
+ #
+ if test -n "$gdk_pixbuf_config" ; then
+ AC_CACHE_CHECK([for gdk-pixbuf includes], ac_cv_gdk_pixbuf_config_cflags,
+ [ac_cv_gdk_pixbuf_config_cflags=`$gdk_pixbuf_config --cflags`])
+ AC_CACHE_CHECK([for gdk-pixbuf libs], ac_cv_gdk_pixbuf_config_libs,
+ [ac_cv_gdk_pixbuf_config_libs=`$gdk_pixbuf_config --libs`])
+ ac_gdk_pixbuf_config_cflags=$ac_cv_gdk_pixbuf_config_cflags
+ ac_gdk_pixbuf_config_libs=$ac_cv_gdk_pixbuf_config_libs
+ fi
+
+ ac_save_gdk_pixbuf_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $ac_gdk_pixbuf_config_cflags"
+
+ # check for header 1...
+ AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf.h, [have_gdk_pixbuf=yes])
+
+ # if that worked, check for header 2...
+ if test "$have_gdk_pixbuf" = yes; then
+ have_gdk_pixbuf=no
+ AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf-xlib.h, [have_gdk_pixbuf=yes])
+ fi
+
+ CPPFLAGS="$ac_save_gdk_pixbuf_CPPFLAGS"
+
+ if test "$have_gdk_pixbuf" = yes; then
+ # we have the headers, now check for the libraries
+ have_gdk_pixbuf=no
+ gdk_pixbuf_halfassed=yes
+ # library 1...
+ AC_CHECK_X_LIB(gdk_pixbuf, gdk_pixbuf_new_from_file,
+ [have_gdk_pixbuf=yes], [true],
+ $ac_gdk_pixbuf_config_libs)
+ # library 2...
+ if test "$have_gdk_pixbuf" = yes; then
+ AC_CHECK_X_LIB(gdk_pixbuf_xlib, gdk_pixbuf_xlib_init,
+ [have_gdk_pixbuf=yes
+ gdk_pixbuf_halfassed=no],
+ [true],
+ $ac_gdk_pixbuf_config_libs)
+ fi
+ fi
+
+ if test "$have_gdk_pixbuf" = yes; then
+ INCLUDES="$INCLUDES $ac_gdk_pixbuf_config_cflags"
+ XPM_LIBS="$ac_gdk_pixbuf_config_libs -lgdk_pixbuf -lgdk_pixbuf_xlib"
+ AC_DEFINE(HAVE_GDK_PIXBUF)
+ fi
+fi
+
+
+###############################################################################
+#
+# Check for -ljpeg
+#
+###############################################################################
+
+have_jpeg=no
+with_jpeg_req=unspecified
+jpeg_halfassed=no
+AC_ARG_WITH(jpeg,
+[ --with-jpeg Include support for the JPEG library in some demos,
+ which will make it possible for them to read JPEG
+ files as well.],
+ [with_jpeg="$withval"; with_jpeg_req="$withval"],
+ [with_jpeg=yes])
+
+HANDLE_X_PATH_ARG(with_jpeg, --with-jpeg, JPEG)
+
+if test "$with_jpeg" != yes -a "$with_jpeg" != no ; then
+ echo "error: must be yes or no: --with-jpeg=$with_jpeg"
+ exit 1
+fi
+
+if test "$with_jpeg" = yes; then
+
+ have_jpeg=no
+ AC_CHECK_X_HEADER(jpeglib.h, [have_jpeg=yes])
+
+ if test "$have_jpeg" = yes; then
+ # we have the header, now check for the library
+ have_jpeg=no
+ jpeg_halfassed=yes
+ AC_CHECK_X_LIB(jpeg, jpeg_start_compress,
+ [have_jpeg=yes
+ jpeg_halfassed=no
+ JPEG_LIBS="-ljpeg"
+ AC_DEFINE(HAVE_JPEGLIB)])
+ fi
+fi
+
+