+###############################################################################
+#
+# 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. (The path here is
+ ignored if GTK 2.x is being used.)],
+ [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
+ have_gdk_pixbuf2=no
+
+ if test -n "$pkg_config" ; then
+ #
+ # the new way...
+ # run pkg-config based tests.
+ #
+ pkgs=''
+ ok="yes"
+ pkg_check_version gdk-pixbuf-2.0 2.0.0
+ pkg_check_version gdk-pixbuf-xlib-2.0 2.0.0
+ have_gdk_pixbuf="$ok"
+ have_gdk_pixbuf2="$ok"
+
+ if test "$have_gdk_pixbuf2" = no; then
+ #
+ # We don't have pixbuf 2.x; check for 1.x.
+ #
+ pkgs=''
+ ok="yes"
+ pkg_check_version gdk-pixbuf 0.0
+ pkg_check_version gdk-pixbuf-xlib 0.0
+ have_gdk_pixbuf="$ok"
+ fi
+
+ if test "$have_gdk_pixbuf" = yes; then
+ AC_CACHE_CHECK([for gdk-pixbuf includes], ac_cv_gdk_pixbuf_config_cflags,
+ [ac_cv_gdk_pixbuf_config_cflags=`$pkg_config --cflags $pkgs`])
+ AC_CACHE_CHECK([for gdk-pixbuf libs], ac_cv_gdk_pixbuf_config_libs,
+ [ac_cv_gdk_pixbuf_config_libs=`$pkg_config --libs $pkgs`])
+ fi
+ ac_gdk_pixbuf_config_cflags=$ac_cv_gdk_pixbuf_config_cflags
+ ac_gdk_pixbuf_config_libs=$ac_cv_gdk_pixbuf_config_libs
+ fi
+
+ if test "$have_gdk_pixbuf" = no; then
+ #
+ # the old way...
+ # run gdk-pixbuf-config based tests.
+ # note that we can't assume that the existence of "pkg-config" means
+ # that we don't have to look for gdk-pixbuf-config -- in Gnome 1.4,
+ # pkg-config exists, but doesn't know about pixbuf.
+ #
+
+ # 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`])
+
+ # note that "gdk-pixbuf-config --libs" produces a link line including
+ # -lgdk_pixbuf, but there's no way to get it to produce one that also
+ # includes -lgdk_pixbuf_xlib. Since we don't know *exactly* what the
+ # name of the library will be, construct it with sed...
+ # M4 sucks!!
+ changequote(X,Y)
+ ac_cv_gdk_pixbuf_config_libs=`echo $ac_cv_gdk_pixbuf_config_libs | \
+ sed 's@ \(-lgdk_pixbuf\([-_a-zA-Z0-9.]*\)\) @ \1 -lgdk_pixbuf_xlib\2 @'`
+ changequote([,])
+
+ ac_gdk_pixbuf_config_cflags=$ac_cv_gdk_pixbuf_config_cflags
+ ac_gdk_pixbuf_config_libs=$ac_cv_gdk_pixbuf_config_libs
+ fi
+ fi
+
+ ac_save_gdk_pixbuf_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $ac_gdk_pixbuf_config_cflags"
+
+ if test "$have_gdk_pixbuf" = no; then
+ #
+ # we appear to have pixbuf; check for headers/libs to be sure.
+ #
+
+ have_gdk_pixbuf=no
+
+ # 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
+ gdk_pixbuf_halfassed=yes
+ AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf-xlib.h,
+ [have_gdk_pixbuf=yes
+ gdk_pixbuf_halfassed=no])
+
+ # yay, it has a new name in GTK2...
+ if test "$have_gdk_pixbuf" = no; then
+ have_gdk_pixbuf=no
+ gdk_pixbuf_halfassed=yes
+ AC_CHECK_X_HEADER(gdk-pixbuf-xlib/gdk-pixbuf-xlib.h,
+ [have_gdk_pixbuf=yes
+ gdk_pixbuf_halfassed=no])
+ fi
+ fi
+ 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(c, gdk_pixbuf_new_from_file, [have_gdk_pixbuf=yes],,
+ $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
+ # library 2...
+ if test "$have_gdk_pixbuf" = yes; then
+ have_gdk_pixbuf=no
+ AC_CHECK_X_LIB(c, gdk_pixbuf_xlib_init,
+ [have_gdk_pixbuf=yes
+ gdk_pixbuf_halfassed=no],,
+ $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
+ fi
+ fi
+
+ if test "$have_gdk_pixbuf" = yes; then
+ INCLUDES="$INCLUDES $ac_gdk_pixbuf_config_cflags"
+ XPM_LIBS="$ac_gdk_pixbuf_config_libs"
+ AC_DEFINE(HAVE_GDK_PIXBUF)
+ else
+ have_gdk_pixbuf2=no
+ 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.
+ (If this library is available, webcollage will be a
+ . lot faster.)],
+ [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
+
+