diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/config.h.in ./config/config.h.in
--- ./config/config.h.in	2005-05-28 12:20:33.000000000 +0200
+++ ./config/config.h.in	2005-06-24 18:01:19.000000000 +0200
@@ -138,3 +138,9 @@
 
 /* Define for large files, on AIX-style hosts. */
 #undef _LARGE_FILES
+
+/* Define to 1 if you have png support in libgd. */
+#undef HAVE_GD_PNG
+
+/* Define to 1 if you have jpg support in libgd. */
+#undef HAVE_GD_JPG
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/configure.in ./config/configure.in
--- ./config/configure.in	2005-06-23 17:43:03.000000000 +0200
+++ ./config/configure.in	2005-06-24 19:10:59.000000000 +0200
@@ -474,9 +474,7 @@
 AC_CHECK_FUNCS(poll,,)
 
 ZLIB=no
-AC_CHECK_LIB(z,inflate,[ZLIB=yes])
-AC_CHECK_HEADERS(zlib.h,,[ZLIB=no])
-
+AC_CHECK_LIB(z,inflate,[AC_CHECK_HEADERS(zlib.h,[ZLIB=yes],)])
 if test "$ZLIB" = "yes"; then
   HAS_ZLIB=true
   ZLIB__UNCOMPRESS_STRING2="Zlib.uncompress_string2 s"
@@ -1023,44 +1021,58 @@
 fi
 
 # testing for gd support
-LIBPNG=no
-AC_CHECK_LIB(png, png_create_read_struct , [LIBPNG=yes])
-
-LIBJPEG=no
-AC_CHECK_LIB(jpeg, jpeg_CreateCompress, [LIBJPEG=yes])
-
-LIBGD_GIF=no
-AC_CHECK_LIB(gd, gdImageGif,[LIBGD_GIF=yes])
-
-LIBGD_PNG=no
-AC_CHECK_LIB(gd, gdImagePng, [LIBGD_PNG=yes])
 
-LIBGD_JPG=no
-AC_CHECK_LIB(gd, gdImageJpeg, [LIBGD_JPG=yes])
-
-AC_MSG_CHECKING(compile with gd)
+HAS_GD=false
+HAS_GD_JPG=false
+HAS_GD_PNG=false
+GD_JPG=no
+GD_PNG=no
 if test "$GD" != "no"; then
   GD=no
-  if test "$ZLIB" = "no"; then
-    echo "you need to install zlib"
-  else
+  LIBGD=no
+  AC_CHECK_LIB(gd, gdImageCreate , [LIBGD=yes])
+  if test "$LIBGD" = "yes"; then
+    LIBPNG=no
+    AC_CHECK_LIB(png, png_create_read_struct , [LIBPNG=yes])
+    LIBGD_PNG=no
+    AC_CHECK_LIB(gd, gdImagePng, [LIBGD_PNG=yes])
     if test "$LIBPNG" = "no"; then
-      echo "you need to install libpng"
+      AC_MSG_NOTICE(png support not available)
     else
-      if test "$LIBJPEG" = "no"; then
-        echo "you need to install libjpeg"
+      if test "$LIBGD_PNG" = "yes"; then
+        GD=yes
+        HAS_GD_PNG=true
+	GD_PNG=yes
+        AC_DEFINE(HAVE_GD_PNG, 1, [Define to 1 if you have png support in libgd.])
+        AC_MSG_NOTICE(using png support in libgd)
       else
-        if test "$LIBGD_PNG" = "yes"; then
-          echo "you need to install gd (libgd-dev)"
-        else
-          if test "$LIBGD_JPG" = "yes"; then
-            GD=yes
-          fi
-        fi
+        HAS_GD_PNG=false
+        AC_MSG_NOTICE(png support not available in libgd)
       fi
     fi
+    LIBJPEG=no
+    AC_CHECK_LIB(jpeg, jpeg_CreateCompress, [LIBJPEG=yes])
+    LIBGD_JPG=no
+    AC_CHECK_LIB(gd, gdImageJpeg, [LIBGD_JPG=yes])
+    if test "$LIBJPEG" = "no"; then
+      AC_MSG_NOTICE(jpeg support not available)
+    else
+      if test "$LIBGD_JPG" = "yes"; then
+        GD=yes
+  	HAS_GD_JPG=true
+	GD_JPG=yes
+        AC_DEFINE(HAVE_GD_JPG, 1, [Define to 1 if you have jpg support in libgd.])
+        AC_MSG_NOTICE(using jpeg support in libgd)
+      else
+  	HAS_GD_JPG=false
+        AC_MSG_NOTICE(jpeg support not available in libgd)
+      fi
+    fi
+  else
+    AC_MSG_NOTICE(libgd not available)
   fi
 fi
+AC_MSG_CHECKING(support for graphical statistics)
 if test "$GD" != "no"; then
   HAS_GD=true
   cp -f ../src/daemon/common/commonGraphics.gd.ml ../src/daemon/common/commonGraphics.ml
@@ -1073,18 +1085,14 @@
 
 MD4ARCH=$arch
 case $host in
-  i386-pc-linux*) MD4COMP=as; MD4ARCH=i386;;
-  i486-pc-linux*) MD4COMP=as; MD4ARCH=i486;;
-  i586-pc-linux*) MD4COMP=as; MD4ARCH=i586;;
-  i686-pc-linux*) MD4COMP=as; MD4ARCH=i686;;
+  i386-pc-linux*|i386-*-*bsd*) MD4COMP=as; MD4ARCH=i386;;
+  i486-pc-linux*|i486-*-*bsd*) MD4COMP=as; MD4ARCH=i486;;
+  i586-pc-linux*|i586-*-*bsd*) MD4COMP=as; MD4ARCH=i586;;
+  i686-pc-linux*|i686-*-*bsd*) MD4COMP=as; MD4ARCH=i686;;
   i386-pc-mingw32*) MD4COMP=cc; MD4ARCH=i386;;
   i486-pc-mingw32*) MD4COMP=cc; MD4ARCH=i486;;
   i586-pc-mingw32*) MD4COMP=cc; MD4ARCH=i586;;
   i686-pc-mingw32*) MD4COMP=cc; MD4ARCH=i686;;
-  i386-*-*bsd*) MD4COMP=as; MD4ARCH=i386;;
-  i486-*-*bsd*) MD4COMP=as; MD4ARCH=i486;;
-  i586-*-*bsd*) MD4COMP=as; MD4ARCH=i586;;
-  i686-*-*bsd*) MD4COMP=as; MD4ARCH=i686;;
   *) MD4COMP=cc;;
 esac
 
@@ -1150,6 +1158,8 @@
 AC_SUBST(MD4COMP)
 AC_SUBST(ZLIB)
 AC_SUBST(GD)
+AC_SUBST(GD_JPG)
+AC_SUBST(GD_PNG)
 AC_SUBST(ICONV)
 
 AC_SUBST(OPEN_NAPSTER)
@@ -1201,6 +1211,8 @@
 AC_SUBST(GTKLLIBS)
 AC_SUBST(GTKLFLAGS)
 AC_SUBST(HAS_GD)
+AC_SUBST(HAS_GD_PNG)
+AC_SUBST(HAS_GD_JPG)
 AC_SUBST(HAS_ZLIB)
 AC_SUBST(ZLIB__UNCOMPRESS_STRING2)
 AC_SUBST(ZLIB__COMPRESS_STRING)
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/Makefile.config.in ./config/Makefile.config.in
--- ./config/Makefile.config.in	2005-06-20 20:52:57.000000000 +0200
+++ ./config/Makefile.config.in	2005-06-24 18:20:34.000000000 +0200
@@ -50,6 +50,8 @@
 ICONV=@ICONV@
 ZLIB=@ZLIB@
 GD=@GD@
+GD_JPG=@GD_JPG@
+GD_PNG=@GD_PNG@
 COMPRESS=@COMPRESS@
 COMPRESS_EXT=@COMPRESS_EXT@
 
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/Makefile.in ./config/Makefile.in
--- ./config/Makefile.in	2005-06-23 00:47:54.000000000 +0200
+++ ./config/Makefile.in	2005-06-24 19:03:55.000000000 +0200
@@ -145,8 +145,15 @@
 endif
 
 ifeq ("$(GD)", "yes")
-  LIBS_flags += -cclib -lgd -cclib -lpng -cclib -ljpeg -cclib -lfreetype -cclib -lm
-  LIBS_flags += -ccopt -DHAVE_JPEG -ccopt -W -ccopt -Wall -ccopt -Wno-unused
+  LIBS_flags += -cclib -lgd -cclib -lfreetype -cclib -lm
+  LIBS_flags += -ccopt -W -ccopt -Wall -ccopt -Wno-unused
+  ifeq ("$(GD_JPG)", "yes")
+    LIBS_flags += -cclib -ljpeg
+  endif
+  ifeq ("$(GD_PNG)", "yes")
+    LIBS_flags += -cclib -lpng
+    LIBS_flags += -ccopt -DHAVE_JPEG
+  endif
   CDK_SRCS +=  $(CDK)/gd.ml $(CDK)/gdstubs.c
 endif
 
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/daemon/common/commonGlobals.ml ./src/daemon/common/commonGlobals.ml
--- ./src/daemon/common/commonGlobals.ml	2005-06-20 20:43:32.000000000 +0200
+++ ./src/daemon/common/commonGlobals.ml	2005-06-24 18:01:19.000000000 +0200
@@ -85,7 +85,10 @@
       ^ "\nFeatures:"
           ^ (if BasicSocket.has_threads () then " threads" else " no-threads")
           ^ (if Autoconf.has_zlib then " zlib" else " no-zlib")
-          ^ (if Autoconf.has_gd then " gd" else " no-gd")
+          ^ (if Autoconf.has_gd && Autoconf.has_gd_png && Autoconf.has_gd_jpg then " gd(jpg/png)" else "")
+	  ^ (if Autoconf.has_gd && Autoconf.has_gd_png && not Autoconf.has_gd_jpg then " gd(png)" else "")
+	  ^ (if Autoconf.has_gd && not Autoconf.has_gd_png && Autoconf.has_gd_jpg then " gd(jpg)" else "")
+	  ^ (if not Autoconf.has_gd then " no-gd" else "")
           ^ (if Autoconf.has_iconv then " iconv" else " no-iconv")
           ^ (if Autoconf.check_bounds then " check-bounds" else " no-check-bounds")
           ^ " " ^ Autoconf.sha1_version
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/daemon/common/commonOptions.ml ./src/daemon/common/commonOptions.ml
--- ./src/daemon/common/commonOptions.ml	2005-06-20 20:56:43.000000000 +0200
+++ ./src/daemon/common/commonOptions.ml	2005-06-24 19:07:51.000000000 +0200
@@ -1511,7 +1511,12 @@
   );
   option_hook client_buffer_size (fun _ ->
       TcpBufferedSocket.max_buffer_size := maxi 50000 !!client_buffer_size
-  )
+  );
+  if Autoconf.has_gd then
+    option_hook html_mods_vd_gfx_png (fun _ ->
+      if not Autoconf.has_gd_png && !!html_mods_vd_gfx_png then html_mods_vd_gfx_png =:= false;
+      if not Autoconf.has_gd_jpg && not !!html_mods_vd_gfx_png then html_mods_vd_gfx_png =:= true
+    )
 
 let verbose_msg_clients = ref false
 let verbose_msg_raw = ref false
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/daemon/driver/driverCommands.ml ./src/daemon/driver/driverCommands.ml
--- ./src/daemon/driver/driverCommands.ml	2005-06-22 20:37:40.000000000 +0200
+++ ./src/daemon/driver/driverCommands.ml	2005-06-24 18:01:19.000000000 +0200
@@ -1380,15 +1380,17 @@
                         strings_of_option display_downloaded_results;
                         strings_of_option vd_reload_delay;
                         strings_of_option html_use_gzip;
-			] @ (if Autoconf.has_gd then [
-                        strings_of_option html_mods_vd_gfx;
+			] @ (if Autoconf.has_gd then
+			[strings_of_option html_mods_vd_gfx;] else []) @
+			(if Autoconf.has_gd_jpg && Autoconf.has_gd_png
+			 then [strings_of_option html_mods_vd_gfx_png;] else []) @
+			(if Autoconf.has_gd then [
                         strings_of_option html_mods_vd_gfx_remove;
                         strings_of_option html_mods_vd_gfx_split;
                         strings_of_option html_mods_vd_gfx_fill;
                         strings_of_option html_mods_vd_gfx_flip;
                         strings_of_option html_mods_vd_gfx_mean;
                         strings_of_option html_mods_vd_gfx_transparent;
-                        strings_of_option html_mods_vd_gfx_png;
                         strings_of_option html_mods_vd_gfx_h;
                         strings_of_option html_mods_vd_gfx_x_size;
                         strings_of_option html_mods_vd_gfx_y_size;
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/cdk/gdstubs.c ./src/utils/cdk/gdstubs.c
--- ./src/utils/cdk/gdstubs.c	2005-04-24 18:24:49.000000000 +0200
+++ ./src/utils/cdk/gdstubs.c	2005-06-24 18:01:19.000000000 +0200
@@ -20,6 +20,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "../../../config/config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -139,6 +141,7 @@
 }
 
 value ml_image_open_png(value filename) {
+#ifdef HAVE_GD_PNG
   CAMLparam1(filename);
   CAMLlocal1(v);
   FILE *in;
@@ -160,10 +163,14 @@
   IM_VAL(v) = im;
 
   CAMLreturn(v);
+#else
+  raise_constant(*(value *)caml_named_value("gd type not supported"));
+  return Val_unit;
+#endif
 }
 
 value ml_image_open_jpeg(value filename) {
-#ifdef HAVE_JPEG
+#ifdef HAVE_GD_JPG
   FILE *in;
   gdImagePtr im;
   CAMLparam1(filename);
@@ -335,17 +342,20 @@
 }
 
 value ml_save_png(value gdw, value filename) {
+#ifdef HAVE_GD_PNG
   FILE *out;
   
   out = fopen(String_val(filename), "wb");
   gdImagePng(IM_VAL(gdw), out);
   fclose(out);
-  
+#else
+  raise_constant(*(value*)caml_named_value("gd type not supported"));
+#endif
   return Val_unit;
 }
 
 value ml_save_jpeg(value gdw, value filename, value quality) {
-#ifdef HAVE_JPEG
+#ifdef HAVE_GD_JPG
   FILE *out;
 
   out = fopen(String_val(filename), "wb");
@@ -365,6 +375,7 @@
 #define Channel(v) (*((struct channel **) (Data_custom_val(v))))
 
 value ml_dump_png(value gdw, value chan) {
+#ifdef HAVE_GD_PNG
   int size;
   void* dat;
 
@@ -372,11 +383,14 @@
   really_putblock(Channel(chan), dat, size);
   free(dat);
   
+#else
+  raise_constant(*(value*)caml_named_value("gd type not supported"));
+#endif
   return Val_unit;
 }
 
 value ml_dump_jpeg(value gdw, value chan, value quality) {
-#ifdef HAVE_JPEG
+#ifdef HAVE_GD_JPG
   int size;
   void* dat;
 
diff -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/autoconf.ml.new.in ./src/utils/lib/autoconf.ml.new.in
--- ./src/utils/lib/autoconf.ml.new.in	2005-06-20 20:52:57.000000000 +0200
+++ ./src/utils/lib/autoconf.ml.new.in	2005-06-24 18:01:19.000000000 +0200
@@ -32,6 +32,8 @@
 let has_iconv = if "@ICONV@" = "yes" then true else false
 
 let has_gd = @HAS_GD@
+let has_gd_png = @HAS_GD_PNG@
+let has_gd_jpg = @HAS_GD_JPG@
 
 let has_zlib = @HAS_ZLIB@
 let zlib__uncompress_string2 s = @ZLIB__UNCOMPRESS_STRING2@
