diff --git a/Magick++/bin/Magick++-config b/Magick++/bin/Magick++-config
index 23f79c4..0d719f8 100755
--- a/Magick++/bin/Magick++-config
+++ b/Magick++/bin/Magick++-config
@@ -55,7 +55,7 @@
       echo '-L/usr/local/lib '
       ;;
     --libs)
-      echo "-L${libdir} -lMagick++ -lMagickWand -lMagickCore -llcms2 -ltiff -ljasper -ljpeg -lpng12 -ldjvulibre -lfontconfig -lXext -lXt -lSM -lICE -lX11 -llzma -lbz2 -lgvc -lgraph -lcdt -lz -lm -lgomp -lpthread -lltdl"
+      echo "-L${libdir} -lMagick++ -lMagickWand -lMagickCore -llcms2 -ltiff -lfreetype -ljasper -ljpeg -lpng12 -ldjvulibre -lfontconfig -lXext -lXt -lSM -lICE -lX11 -llzma -lbz2 -lxml2 -lgvc -lgraph -lcdt -lz -lm -lgomp -lpthread -lltdl"
       ;;
     *)
       echo "${usage}" 1>&2
diff --git a/MagickCore/magick-config.h b/MagickCore/magick-config.h
index 5e8edff..df4049a 100644
--- a/MagickCore/magick-config.h
+++ b/MagickCore/magick-config.h
@@ -95,7 +95,7 @@
 /* Define if you have FlashPIX library */
 /* #undef FPX_DELEGATE */
 
-/* Define if you have FREETYPE library */
+/* Define if you have FreeType (TrueType font) library */
 #ifndef MAGICKCORE_FREETYPE_DELEGATE
 #define MAGICKCORE_FREETYPE_DELEGATE 1
 #endif
@@ -340,6 +340,11 @@
 #define MAGICKCORE_HAVE_FSEEKO 1
 #endif
 
+/* Define to 1 if you have the <ft2build.h> header file. */
+#ifndef MAGICKCORE_HAVE_FT2BUILD_H
+#define MAGICKCORE_HAVE_FT2BUILD_H 1
+#endif
+
 /* Define to 1 if you have the `ftime' function. */
 #ifndef MAGICKCORE_HAVE_FTIME
 #define MAGICKCORE_HAVE_FTIME 1
@@ -1226,7 +1231,7 @@
 #define MAGICKCORE_LT_OBJDIR ".libs/"
 #endif
 
-/* Define if you have LZMA library */
+/* Define if you have lzma compression library */
 #ifndef MAGICKCORE_LZMA_DELEGATE
 #define MAGICKCORE_LZMA_DELEGATE 1
 #endif
diff --git a/Makefile.in b/Makefile.in
index 7381d88..20a8ea9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2346,9 +2346,6 @@
 EXEEXT = @EXEEXT@
 EchoDelegate = @EchoDelegate@
 EditorDelegate = @EditorDelegate@
-FFTW3_CFLAGS = @FFTW3_CFLAGS@
-FFTW3_LIBS = @FFTW3_LIBS@
-FFTW_CFLAGS = @FFTW_CFLAGS@
 FFTW_LIBS = @FFTW_LIBS@
 FGREP = @FGREP@
 FIGDecodeDelegate = @FIGDecodeDelegate@
@@ -2356,9 +2353,6 @@
 FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
 FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
 FPX_LIBS = @FPX_LIBS@
-FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
-FREETYPE2_LIBS = @FREETYPE2_LIBS@
-FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
 FREETYPE_LIBS = @FREETYPE_LIBS@
 GDI32_LIBS = @GDI32_LIBS@
 GOMP_LIBS = @GOMP_LIBS@
@@ -2432,7 +2426,6 @@
 LT_CONFIG_H = @LT_CONFIG_H@
 LT_DLLOADERS = @LT_DLLOADERS@
 LT_DLPREOPEN = @LT_DLPREOPEN@
-LZMA_CFLAGS = @LZMA_CFLAGS@
 LZMA_LIBS = @LZMA_LIBS@
 LZWDecodeDelegate = @LZWDecodeDelegate@
 LZWEncodeDelegate = @LZWEncodeDelegate@
@@ -2518,7 +2511,6 @@
 PERSISTINCLUDE_DIR = @PERSISTINCLUDE_DIR@
 PGPDecodeDelegate = @PGPDecodeDelegate@
 PKG_CONFIG = @PKG_CONFIG@
-PNG_CFLAGS = @PNG_CFLAGS@
 PNG_LIBS = @PNG_LIBS@
 POVDelegate = @POVDelegate@
 POW_LIB = @POW_LIB@
@@ -2571,9 +2563,6 @@
 X11_LIBS = @X11_LIBS@
 XEXT_LIBS = @XEXT_LIBS@
 XMKMF = @XMKMF@
-XML2_CFLAGS = @XML2_CFLAGS@
-XML2_LIBS = @XML2_LIBS@
-XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XPSCMYKDevice = @XPSCMYKDevice@
 XPSColorDevice = @XPSColorDevice@
@@ -2616,6 +2605,7 @@
 docdir = $(DOCUMENTATION_PATH)
 dvidir = @dvidir@
 exec_prefix = @exec_prefix@
+freetype_config = @freetype_config@
 ghostscript_font_dir = @ghostscript_font_dir@
 host = @host@
 host_alias = @host_alias@
@@ -2654,6 +2644,7 @@
 top_srcdir = @top_srcdir@
 type_include_files = @type_include_files@
 windows_font_dir = @windows_font_dir@
+xml2_config = @xml2_config@
 AUTOMAKE_OPTIONS = 1.11 subdir-objects parallel-tests color-tests dist-zip dist-bzip2 dist-xz foreign
 topincludedir = @includedir@/ImageMagick
 
diff --git a/PerlMagick/Makefile.PL b/PerlMagick/Makefile.PL
index fc2a953..294675b 100644
--- a/PerlMagick/Makefile.PL
+++ b/PerlMagick/Makefile.PL
@@ -156,7 +156,7 @@
 }
 
 # defaults for LIBS & INC & CCFLAGS params that we later pass to Writemakefile
-my $INC_magick = '-I../ -I.. -pthread -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libpng12 -I/usr/include/graphviz -I"' . $Config{'usrinc'} . '/ImageMagick"';
+my $INC_magick = '-I../ -I.. -pthread -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/graphviz -I/usr/include/freetype2 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"';
 my $LIBS_magick = '-L../MagickCore/.libs -lMagickCore -lperl -lm';
 my $CCFLAGS_magick = "$Config{'ccflags'} -fopenmp -g -O2 -Wall -pthread";
 my $LDFLAGS_magick   = "-L../MagickCore/.libs -lMagickCore $Config{'ldflags'} ";
@@ -201,7 +201,7 @@
    #'CC' => 'gcc -std=gnu99 -std=gnu99',
 
    # C pre-processor flags (e.g. -I & -D options)
-   # 'CPPFLAGS' => "$Config{'cppflags'} -pthread -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libpng12 -I/usr/include/graphviz",
+   # 'CPPFLAGS' => "$Config{'cppflags'} -pthread -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/graphviz -I/usr/include/freetype2 -I/usr/include/libxml2",
 
    # C compiler flags (e.g. -O -g)
    'CCFLAGS' => $CCFLAGS_magick,
diff --git a/config/config.h.in b/config/config.h.in
index 5bd7799..9d5681d 100644
--- a/config/config.h.in
+++ b/config/config.h.in
@@ -64,7 +64,7 @@
 /* Define if you have FlashPIX library */
 #undef FPX_DELEGATE
 
-/* Define if you have FREETYPE library */
+/* Define if you have FreeType (TrueType font) library */
 #undef FREETYPE_DELEGATE
 
 /* Define if you have Ghostscript library or framework */
@@ -227,6 +227,9 @@
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 #undef HAVE_FSEEKO
 
+/* Define to 1 if you have the <ft2build.h> header file. */
+#undef HAVE_FT2BUILD_H
+
 /* Define to 1 if you have the `ftime' function. */
 #undef HAVE_FTIME
 
@@ -805,7 +808,7 @@
    */
 #undef LT_OBJDIR
 
-/* Define if you have LZMA library */
+/* Define if you have lzma compression library */
 #undef LZMA_DELEGATE
 
 /* Define to prepend to default font search path. */
diff --git a/config/configure.xml b/config/configure.xml
index 70fcf6f..abaa2f8 100644
--- a/config/configure.xml
+++ b/config/configure.xml
@@ -28,7 +28,7 @@
   <configure name="PCFLAGS" value="-fopenmp"/>
   <configure name="DEFS" value="-DHAVE_CONFIG_H"/>
   <configure name="LDFLAGS" value="-L/usr/local/lib "/>
-  <configure name="LIBS" value="-lMagickCore -llcms2 -ltiff -ljasper -ljpeg -lpng12 -ldjvulibre -lfontconfig -lXext -lXt -lSM -lICE -lX11 -llzma -lbz2 -lgvc -lgraph -lcdt -lz -lm -lgomp -lpthread -lltdl"/>
+  <configure name="LIBS" value="-lMagickCore -llcms2 -ltiff -lfreetype -ljasper -ljpeg -lpng12 -ldjvulibre -lfontconfig -lXext -lXt -lSM -lICE -lX11 -llzma -lbz2 -lxml2 -lgvc -lgraph -lcdt -lz -lm -lgomp -lpthread -lltdl"/>
   <configure name="CXX" value="g++"/>
   <configure name="CXXFLAGS" value="-g -O2 -pthread"/>
   <configure name="DISTCHECK_CONFIG_FLAGS" value="--disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-perl=no"/>
diff --git a/configure b/configure
index 417c20f..83e0db9 100755
--- a/configure
+++ b/configure
@@ -730,11 +730,9 @@
 EXECUTABLE_PATH
 PERLMAINCC
 XML_LIBS
-XML_CFLAGS
 XML_DELEGATE_FALSE
 XML_DELEGATE_TRUE
-XML2_LIBS
-XML2_CFLAGS
+xml2_config
 WMF_LIBS
 WMF_DELEGATE_FALSE
 WMF_DELEGATE_TRUE
@@ -752,18 +750,16 @@
 CAIRO_SVG_CFLAGS
 RSVG_LIBS
 RSVG_CFLAGS
+PNG_LIBS
 PNG_DELEGATE_FALSE
 PNG_DELEGATE_TRUE
-PNG_LIBS
-PNG_CFLAGS
 OPENEXR_DELEGATE_FALSE
 OPENEXR_DELEGATE_TRUE
 OPENEXR_LIBS
 OPENEXR_CFLAGS
+LZMA_LIBS
 LZMA_DELEGATE_FALSE
 LZMA_DELEGATE_TRUE
-LZMA_LIBS
-LZMA_CFLAGS
 LQR_DELEGATE_FALSE
 LQR_DELEGATE_TRUE
 LQR_LIBS
@@ -788,11 +784,9 @@
 GS_DELEGATE_FALSE
 GS_DELEGATE_TRUE
 FREETYPE_LIBS
-FREETYPE_CFLAGS
 FREETYPE_DELEGATE_FALSE
 FREETYPE_DELEGATE_TRUE
-FREETYPE2_LIBS
-FREETYPE2_CFLAGS
+freetype_config
 FONTCONFIG_DELEGATE_FALSE
 FONTCONFIG_DELEGATE_TRUE
 FONTCONFIG_LIBS
@@ -801,11 +795,8 @@
 FPX_DELEGATE_FALSE
 FPX_DELEGATE_TRUE
 FFTW_LIBS
-FFTW_CFLAGS
 FFTW_DELEGATE_FALSE
 FFTW_DELEGATE_TRUE
-FFTW3_LIBS
-FFTW3_CFLAGS
 DJVU_LIBS
 DJVU_DELEGATE_FALSE
 DJVU_DELEGATE_TRUE
@@ -1171,28 +1162,18 @@
 XMKMF
 AUTOTRACE_CFLAGS
 AUTOTRACE_LIBS
-FFTW3_CFLAGS
-FFTW3_LIBS
 FONTCONFIG_CFLAGS
 FONTCONFIG_LIBS
-FREETYPE2_CFLAGS
-FREETYPE2_LIBS
 GVC_CFLAGS
 GVC_LIBS
 LQR_CFLAGS
 LQR_LIBS
-LZMA_CFLAGS
-LZMA_LIBS
 OPENEXR_CFLAGS
 OPENEXR_LIBS
-PNG_CFLAGS
-PNG_LIBS
 RSVG_CFLAGS
 RSVG_LIBS
 CAIRO_SVG_CFLAGS
-CAIRO_SVG_LIBS
-XML2_CFLAGS
-XML2_LIBS'
+CAIRO_SVG_LIBS'
 
 
 # Initialize some variables set by options.
@@ -1896,7 +1877,7 @@
   --without-fftw          disable FFTW support
   --without-fpx           disable FlashPIX support
   --without-fontconfig    disable fontconfig support
-  --without-freetype      disable FREETYPE support
+  --without-freetype      disable Freetype support
   --without-gslib         enable Ghostscript library support
   --with-fontpath=DIR     prepend to default font search path
   --with-gs-font-dir=DIR  Ghostscript font directory
@@ -1936,37 +1917,24 @@
               C compiler flags for AUTOTRACE, overriding pkg-config
   AUTOTRACE_LIBS
               linker flags for AUTOTRACE, overriding pkg-config
-  FFTW3_CFLAGS
-              C compiler flags for FFTW3, overriding pkg-config
-  FFTW3_LIBS  linker flags for FFTW3, overriding pkg-config
   FONTCONFIG_CFLAGS
               C compiler flags for FONTCONFIG, overriding pkg-config
   FONTCONFIG_LIBS
               linker flags for FONTCONFIG, overriding pkg-config
-  FREETYPE2_CFLAGS
-              C compiler flags for FREETYPE2, overriding pkg-config
-  FREETYPE2_LIBS
-              linker flags for FREETYPE2, overriding pkg-config
   GVC_CFLAGS  C compiler flags for GVC, overriding pkg-config
   GVC_LIBS    linker flags for GVC, overriding pkg-config
   LQR_CFLAGS  C compiler flags for LQR, overriding pkg-config
   LQR_LIBS    linker flags for LQR, overriding pkg-config
-  LZMA_CFLAGS C compiler flags for LZMA, overriding pkg-config
-  LZMA_LIBS   linker flags for LZMA, overriding pkg-config
   OPENEXR_CFLAGS
               C compiler flags for OPENEXR, overriding pkg-config
   OPENEXR_LIBS
               linker flags for OPENEXR, overriding pkg-config
-  PNG_CFLAGS  C compiler flags for PNG, overriding pkg-config
-  PNG_LIBS    linker flags for PNG, overriding pkg-config
   RSVG_CFLAGS C compiler flags for RSVG, overriding pkg-config
   RSVG_LIBS   linker flags for RSVG, overriding pkg-config
   CAIRO_SVG_CFLAGS
               C compiler flags for CAIRO_SVG, overriding pkg-config
   CAIRO_SVG_LIBS
               linker flags for CAIRO_SVG, overriding pkg-config
-  XML2_CFLAGS C compiler flags for XML2, overriding pkg-config
-  XML2_LIBS   linker flags for XML2, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -28214,90 +28182,89 @@
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fftw=$with_fftw "
 fi
 
-FFTW_PKG=""
-if test "x$with_fftw" = "xyes"; then
+have_fftw='no'
+FFTW_LIBS=''
+if test "$with_fftw" != 'no'; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: -------------------------------------------------------------" >&5
 $as_echo "-------------------------------------------------------------" >&6; }
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FFTW3" >&5
-$as_echo_n "checking for FFTW3... " >&6; }
-
-if test -n "$FFTW3_CFLAGS"; then
-    pkg_cv_FFTW3_CFLAGS="$FFTW3_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fftw3\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "fftw3") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_FFTW3_CFLAGS=`$PKG_CONFIG --cflags "fftw3" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$FFTW3_LIBS"; then
-    pkg_cv_FFTW3_LIBS="$FFTW3_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fftw3\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "fftw3") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_FFTW3_LIBS=`$PKG_CONFIG --libs "fftw3" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        FFTW3_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "fftw3" 2>&1`
-        else
-	        FFTW3_PKG_ERRORS=`$PKG_CONFIG --print-errors "fftw3" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$FFTW3_PKG_ERRORS" >&5
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-                have_fftw=no
-elif test $pkg_failed = untried; then
-	have_fftw=no
-else
-	FFTW3_CFLAGS=$pkg_cv_FFTW3_CFLAGS
-	FFTW3_LIBS=$pkg_cv_FFTW3_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	have_fftw=yes
-fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FFTW" >&5
+$as_echo_n "checking for FFTW... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
+    failed=0
+    passed=0
+    ac_fn_c_check_header_mongrel "$LINENO" "fftw3.h" "ac_cv_header_fftw3_h" "$ac_includes_default"
+if test "x$ac_cv_header_fftw3_h" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
 fi
 
-if test "$have_fftw" = 'yes'; then
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fftw_execute in -lfftw3" >&5
+$as_echo_n "checking for fftw_execute in -lfftw3... " >&6; }
+if ${ac_cv_lib_fftw3_fftw_execute+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lfftw3  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char fftw_execute ();
+int
+main ()
+{
+return fftw_execute ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_fftw3_fftw_execute=yes
+else
+  ac_cv_lib_fftw3_fftw_execute=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fftw3_fftw_execute" >&5
+$as_echo "$ac_cv_lib_fftw3_fftw_execute" >&6; }
+if test "x$ac_cv_lib_fftw3_fftw_execute" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if FFTW package is complete" >&5
+$as_echo_n "checking if FFTW package is complete... " >&6; }
+    if test $passed -gt 0; then
+        if test $failed -gt 0; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+$as_echo "no -- some components failed test" >&6; }
+            have_fftw='no (failed tests)'
+        else
+            FFTW_LIBS='-lfftw3'
+            LIBS="$FFTW_LIBS $LIBS"
 
 $as_echo "#define FFTW_DELEGATE 1" >>confdefs.h
 
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$FFTW_CFLAGS $CPPFLAGS"
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+            have_fftw='yes'
+        fi
+    else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
     fi
 fi
-
  if test "$have_fftw" = 'yes'; then
   FFTW_DELEGATE_TRUE=
   FFTW_DELEGATE_FALSE='#'
@@ -28309,7 +28276,6 @@
 
 
 
-
 #
 # Check for FlashPIX delegate library.
 #
@@ -28549,7 +28515,7 @@
 
 
 #
-# Check for FREETYPE delegate library.
+# Check for freetype delegate library.
 #
 
 # Check whether --with-freetype was given.
@@ -28560,94 +28526,177 @@
 fi
 
 
+
 if test "$with_freetype" != 'yes'; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-freetype=$with_freetype "
 fi
 
-FREETYPE_PKG=""
-if test "x$with_freetype" = "xyes"; then
+have_freetype='no'
+FREETYPE_LIBS=''
+if test "$with_freetype" != 'no'; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: -------------------------------------------------------------" >&5
 $as_echo "-------------------------------------------------------------" >&6; }
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FREETYPE2" >&5
-$as_echo_n "checking for FREETYPE2... " >&6; }
-
-if test -n "$FREETYPE2_CFLAGS"; then
-    pkg_cv_FREETYPE2_CFLAGS="$FREETYPE2_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "freetype2") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags "freetype2" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$FREETYPE2_LIBS"; then
-    pkg_cv_FREETYPE2_LIBS="$FREETYPE2_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "freetype2") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_FREETYPE2_LIBS=`$PKG_CONFIG --libs "freetype2" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        FREETYPE2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "freetype2" 2>&1`
-        else
-	        FREETYPE2_PKG_ERRORS=`$PKG_CONFIG --print-errors "freetype2" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$FREETYPE2_PKG_ERRORS" >&5
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-                have_freetype=no
-elif test $pkg_failed = untried; then
-	have_freetype=no
-else
-	FREETYPE2_CFLAGS=$pkg_cv_FREETYPE2_CFLAGS
-	FREETYPE2_LIBS=$pkg_cv_FREETYPE2_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	have_freetype=yes
-fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeType 2.0" >&5
+$as_echo_n "checking for FreeType 2.0... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
+    failed=0
+    passed=0
+    PERSIST_LIBS="$LIBS"
+    PERSIST_CPPFLAGS="$CPPFLAGS"
+    if test "$enable_delegate_build" != 'no' && test -d "$builddir/freetype/include"; then
+        :
+    else
+        freetype_config=''
+        for ac_prog in freetype-config
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_freetype_config+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$freetype_config"; then
+  ac_cv_prog_freetype_config="$freetype_config" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_freetype_config="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+freetype_config=$ac_cv_prog_freetype_config
+if test -n "$freetype_config"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $freetype_config" >&5
+$as_echo "$freetype_config" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-if test "$have_freetype" = 'yes'; then
+
+  test -n "$freetype_config" && break
+done
+        if test -n "$freetype_config"; then
+            freetype_cflags=`$freetype_config --cflags`
+            freetype_libs=`$freetype_config --libs`
+            LIBS="$LIBS $freetype_libs"
+            CPPFLAGS="$freetype_cflags $CPPFLAGS"
+        fi
+    fi
+
+    if test "$FREETYPE_LIBS" = ''; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5
+$as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; }
+if ${ac_cv_lib_freetype_FT_Init_FreeType+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lfreetype  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char FT_Init_FreeType ();
+int
+main ()
+{
+return FT_Init_FreeType ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_freetype_FT_Init_FreeType=yes
+else
+  ac_cv_lib_freetype_FT_Init_FreeType=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5
+$as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; }
+if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = xyes; then :
+  FREETYPE_LIBS='-lfreetype'
+fi
+
+        if test "$FREETYPE_LIBS" != ''; then
+            passed=`expr $passed + 1`
+        else
+            failed=`expr $failed + 1`
+            LIBS="$PERSIST_LIBS"
+        fi
+    fi
+
+    ac_fn_c_check_header_mongrel "$LINENO" "ft2build.h" "ac_cv_header_ft2build_h" "$ac_includes_default"
+if test "x$ac_cv_header_ft2build_h" = xyes; then :
+  FT2BUILD_H='#include <ft2build.h>'
+else
+  ft2build=''
+fi
+
+
+    ac_fn_c_check_header_compile "$LINENO" "freetype/freetype.h" "ac_cv_header_freetype_freetype_h" "$FT2BUILD_H
+"
+if test "x$ac_cv_header_freetype_freetype_h" = xyes; then :
+  have_freetype_h='yes'
+else
+  have_freetype_h='no'
+fi
+
+
+    if test "$ac_cv_header_ft2build_h" = 'yes' || test "$have_freetype_h" = 'yes'; then
+        passed=`expr $passed + 1`
+    else
+        failed=`expr $failed + 1`
+        CPPFLAGS="$PERSIST_CPPFLAGS"
+    fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if FreeType package is complete" >&5
+$as_echo_n "checking if FreeType package is complete... " >&6; }
+    if test $passed -gt 0; then
+        if test $failed -gt 0; then
+            FREETYPE_LIBS=''
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+$as_echo "no -- some components failed test" >&6; }
+            have_freetype='no (failed tests)'
+        else
+            LIBS="$FREETYPE_LIBS $LIBS"
 
 $as_echo "#define FREETYPE_DELEGATE 1" >>confdefs.h
 
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$FREETYPE_CFLAGS $CPPFLAGS"
+            if test "$ac_cv_header_ft2build_h" = 'yes'; then
+
+$as_echo "#define HAVE_FT2BUILD_H 1" >>confdefs.h
+
+            fi
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+            have_freetype='yes'
+        fi
+    else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
     fi
 fi
-
  if test "$have_freetype" = 'yes'; then
   FREETYPE_DELEGATE_TRUE=
   FREETYPE_DELEGATE_FALSE='#'
@@ -28660,8 +28709,6 @@
 
 
 
-
-
 #
 # Check for Ghostscript library or framework.
 #
@@ -29756,9 +29803,7 @@
 
 
 
-#
-# Check for LZMA delegate library.
-#
+# Disable LZMA (lzma library)
 
 # Check whether --with-lzma was given.
 if test "${with_lzma+set}" = set; then :
@@ -29767,95 +29812,96 @@
   with_lzma='yes'
 fi
 
-
-if test "$with_lzma" != 'yes'; then
+if test "$with_lzma" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-lzma=$with_lzma "
 fi
 
-LZMA_PKG=""
-if test "x$with_lzma" = "xyes"; then
+#
+# Check for LZMA
+#
+have_lzma='no'
+LZMA_LIBS=''
+if test "$with_lzma" != 'no' || test "$with_tiff" != 'no'; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: -------------------------------------------------------------" >&5
 $as_echo "-------------------------------------------------------------" >&6; }
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LZMA" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LZMA" >&5
 $as_echo_n "checking for LZMA... " >&6; }
-
-if test -n "$LZMA_CFLAGS"; then
-    pkg_cv_LZMA_CFLAGS="$LZMA_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblzma\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "liblzma") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_LZMA_CFLAGS=`$PKG_CONFIG --cflags "liblzma" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$LZMA_LIBS"; then
-    pkg_cv_LZMA_LIBS="$LZMA_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblzma\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "liblzma") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_LZMA_LIBS=`$PKG_CONFIG --libs "liblzma" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        LZMA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "liblzma" 2>&1`
-        else
-	        LZMA_PKG_ERRORS=`$PKG_CONFIG --print-errors "liblzma" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$LZMA_PKG_ERRORS" >&5
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-                have_lzma=no
-elif test $pkg_failed = untried; then
-	have_lzma=no
-else
-	LZMA_CFLAGS=$pkg_cv_LZMA_CFLAGS
-	LZMA_LIBS=$pkg_cv_LZMA_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	have_lzma=yes
-fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
+  failed=0
+  passed=0
+  ac_fn_c_check_header_mongrel "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default"
+if test "x$ac_cv_header_lzma_h" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
 fi
 
-if test "$have_lzma" = 'yes'; then
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_code in -llzma" >&5
+$as_echo_n "checking for lzma_code in -llzma... " >&6; }
+if ${ac_cv_lib_lzma_lzma_code+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-llzma  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char lzma_code ();
+int
+main ()
+{
+return lzma_code ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_lzma_lzma_code=yes
+else
+  ac_cv_lib_lzma_lzma_code=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_code" >&5
+$as_echo "$ac_cv_lib_lzma_lzma_code" >&6; }
+if test "x$ac_cv_lib_lzma_lzma_code" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if LZMA package is complete" >&5
+$as_echo_n "checking if LZMA package is complete... " >&6; }
+  if test $passed -gt 0; then
+    if test $failed -gt 0; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+$as_echo "no -- some components failed test" >&6; }
+      have_lzma='no (failed tests)'
+    else
+      LZMA_LIBS='-llzma'
+      LIBS="$LZMA_LIBS $LIBS"
 
 $as_echo "#define LZMA_DELEGATE 1" >>confdefs.h
 
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$LZMA_CFLAGS $CPPFLAGS"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      have_lzma='yes'
     fi
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  fi
 fi
-
  if test "$have_lzma" = 'yes'; then
   LZMA_DELEGATE_TRUE=
   LZMA_DELEGATE_FALSE='#'
@@ -29867,7 +29913,6 @@
 
 
 
-
 #
 # Check for the OpenEXR delegate library.
 #
@@ -29999,88 +30044,370 @@
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-png=$with_png "
 fi
 
-PNG_PKG=""
-if test "x$with_png" = "xyes"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: -------------------------------------------------------------" >&5
+have_png='no'
+PNG_LIBS=''
+
+if test "$with_png" != 'no' -a  "$have_zlib" != 'no' ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: -------------------------------------------------------------" >&5
 $as_echo "-------------------------------------------------------------" >&6; }
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PNG" >&5
-$as_echo_n "checking for PNG... " >&6; }
-
-if test -n "$PNG_CFLAGS"; then
-    pkg_cv_PNG_CFLAGS="$PNG_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpng\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libpng") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_PNG_CFLAGS=`$PKG_CONFIG --cflags "libpng" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$PNG_LIBS"; then
-    pkg_cv_PNG_LIBS="$PNG_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpng\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libpng") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_PNG_LIBS=`$PKG_CONFIG --libs "libpng" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        PNG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libpng" 2>&1`
-        else
-	        PNG_PKG_ERRORS=`$PKG_CONFIG --print-errors "libpng" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$PNG_PKG_ERRORS" >&5
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-                have_png=no
-elif test $pkg_failed = untried; then
-	have_png=no
-else
-	PNG_CFLAGS=$pkg_cv_PNG_CFLAGS
-	PNG_LIBS=$pkg_cv_PNG_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	have_png=yes
-fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PNG support " >&5
+$as_echo_n "checking for PNG support ... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
+  failed=0
+  passed=0
+  ac_fn_c_check_header_mongrel "$LINENO" "png.h" "ac_cv_header_png_h" "$ac_includes_default"
+if test "x$ac_cv_header_png_h" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
 fi
 
-if test "$have_png" = 'yes'; then
+
+
+  if test $passed -gt 0; then
+    for var in 5 4 2 '' ; do
+      if test "$have_png" == 'no' ; then
+        if test "x${var}" == 'x' ; then
+          pnglib='png'
+        else
+          pnglib="png1${var}"
+        fi
+
+#       Test for compatible LIBPNG library
+        failed=0
+        passed=0
+        if test "$with_png" == 'yes' -o "$with_png" == "libpng1${var}" ; then
+          if test "${pnglib}" != 'png' ; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBPNG1${var} support " >&5
+$as_echo_n "checking for LIBPNG1${var} support ... " >&6; }
+            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stdlib.h>
+#include <png.h>
+
+int
+main ()
+{
+
+#if PNG_LIBPNG_VER_MINOR != ${var}
+#error LIBPNG library must be version 1${var}!
+Kaboom, Kaboom
+#endif
+return 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+              ac_cv_libpng_ok='yes'
+else
+  ac_cv_libpng_ok='no'
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+            if test "$ac_cv_libpng_ok" = 'yes' ; then
+              passed=`expr $passed + 1`
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+            else
+              failed=`expr $failed + 1`
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+            fi
+          else
+            passed=`expr $passed + 1`
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+          fi
+        fi
+
+        if test $passed -gt 0 -a $failed -le 0; then
+          if test "1${var}" = '15' ; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_get_io_ptr in -lpng15" >&5
+$as_echo_n "checking for png_get_io_ptr in -lpng15... " >&6; }
+if ${ac_cv_lib_png15_png_get_io_ptr+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng15  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char png_get_io_ptr ();
+int
+main ()
+{
+return png_get_io_ptr ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_png15_png_get_io_ptr=yes
+else
+  ac_cv_lib_png15_png_get_io_ptr=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png15_png_get_io_ptr" >&5
+$as_echo "$ac_cv_lib_png15_png_get_io_ptr" >&6; }
+if test "x$ac_cv_lib_png15_png_get_io_ptr" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_longjmp in -lpng15" >&5
+$as_echo_n "checking for png_longjmp in -lpng15... " >&6; }
+if ${ac_cv_lib_png15_png_longjmp+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng15  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char png_longjmp ();
+int
+main ()
+{
+return png_longjmp ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_png15_png_longjmp=yes
+else
+  ac_cv_lib_png15_png_longjmp=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png15_png_longjmp" >&5
+$as_echo "$ac_cv_lib_png15_png_longjmp" >&6; }
+if test "x$ac_cv_lib_png15_png_longjmp" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+          fi
+          if test "1${var}" = '14' ; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_get_io_ptr in -lpng14" >&5
+$as_echo_n "checking for png_get_io_ptr in -lpng14... " >&6; }
+if ${ac_cv_lib_png14_png_get_io_ptr+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng14  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char png_get_io_ptr ();
+int
+main ()
+{
+return png_get_io_ptr ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_png14_png_get_io_ptr=yes
+else
+  ac_cv_lib_png14_png_get_io_ptr=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png14_png_get_io_ptr" >&5
+$as_echo "$ac_cv_lib_png14_png_get_io_ptr" >&6; }
+if test "x$ac_cv_lib_png14_png_get_io_ptr" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_get_io_state in -lpng14" >&5
+$as_echo_n "checking for png_get_io_state in -lpng14... " >&6; }
+if ${ac_cv_lib_png14_png_get_io_state+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng14  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char png_get_io_state ();
+int
+main ()
+{
+return png_get_io_state ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_png14_png_get_io_state=yes
+else
+  ac_cv_lib_png14_png_get_io_state=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png14_png_get_io_state" >&5
+$as_echo "$ac_cv_lib_png14_png_get_io_state" >&6; }
+if test "x$ac_cv_lib_png14_png_get_io_state" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+          fi
+          if test "1${var}" = '12' ; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_get_io_ptr in -lpng12" >&5
+$as_echo_n "checking for png_get_io_ptr in -lpng12... " >&6; }
+if ${ac_cv_lib_png12_png_get_io_ptr+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng12  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char png_get_io_ptr ();
+int
+main ()
+{
+return png_get_io_ptr ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_png12_png_get_io_ptr=yes
+else
+  ac_cv_lib_png12_png_get_io_ptr=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png12_png_get_io_ptr" >&5
+$as_echo "$ac_cv_lib_png12_png_get_io_ptr" >&6; }
+if test "x$ac_cv_lib_png12_png_get_io_ptr" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+          fi
+          if test "1${var}" = '1' ; then
+              { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_get_io_ptr in -lpng" >&5
+$as_echo_n "checking for png_get_io_ptr in -lpng... " >&6; }
+if ${ac_cv_lib_png_png_get_io_ptr+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpng  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char png_get_io_ptr ();
+int
+main ()
+{
+return png_get_io_ptr ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_png_png_get_io_ptr=yes
+else
+  ac_cv_lib_png_png_get_io_ptr=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_png_get_io_ptr" >&5
+$as_echo "$ac_cv_lib_png_png_get_io_ptr" >&6; }
+if test "x$ac_cv_lib_png_png_get_io_ptr" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+          fi
+          if test $passed -gt 0 -a $failed -le 0 ; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${pnglib} package is complete" >&5
+$as_echo_n "checking if ${pnglib} package is complete... " >&6; }
+            if test $passed -gt 0 ; then
+              if test $failed -gt 0 ; then
+                  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+$as_echo "no -- some components failed test" >&6; }
+                  have_png='no (failed tests)'
+              else
+                  PNG_LIBS="-l${pnglib}"
+                  LIBS="$PNG_LIBS $LIBS"
 
 $as_echo "#define PNG_DELEGATE 1" >>confdefs.h
 
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$PNG_CFLAGS $CPPFLAGS"
-    fi
+                  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+                  have_png='yes'
+              fi
+            fi
+          fi
+        fi
+      fi
+    done
+  fi
 fi
 
  if test "$have_png" = 'yes'; then
@@ -30887,6 +31214,8 @@
 
 
 
+
+
 #
 # Check for XML delegate library.
 #
@@ -30895,98 +31224,237 @@
 if test "${with_xml+set}" = set; then :
   withval=$with_xml; with_xml=$withval
 else
-  with_xml='yes'
+  with_xml=$have_x
 fi
 
 
-if test "$with_xml" != 'yes'; then
+if test "$with_xml" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-xml=$with_xml "
 fi
 
-XML_PKG=""
-if test "x$with_xml" = "xyes"; then
+have_xml='no'
+XML_LIBS=''
+if test "$with_xml" != 'no'; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: -------------------------------------------------------------" >&5
 $as_echo "-------------------------------------------------------------" >&6; }
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML2" >&5
-$as_echo_n "checking for XML2... " >&6; }
-
-if test -n "$XML2_CFLAGS"; then
-    pkg_cv_XML2_CFLAGS="$XML2_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_XML2_CFLAGS=`$PKG_CONFIG --cflags "libxml-2.0" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$XML2_LIBS"; then
-    pkg_cv_XML2_LIBS="$XML2_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  pkg_cv_XML2_LIBS=`$PKG_CONFIG --libs "libxml-2.0" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        XML2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libxml-2.0" 2>&1`
-        else
-	        XML2_PKG_ERRORS=`$PKG_CONFIG --print-errors "libxml-2.0" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$XML2_PKG_ERRORS" >&5
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-                have_xml=no
-elif test $pkg_failed = untried; then
-	have_xml=no
-else
-	XML2_CFLAGS=$pkg_cv_XML2_CFLAGS
-	XML2_LIBS=$pkg_cv_XML2_LIBS
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	have_xml=yes
-fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML" >&5
+$as_echo_n "checking for XML... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
+    PERSIST_LDFLAGS=$LDFLAGS
+    PERSIST_CPPFLAGS=$CPPFLAGS
+    xml2_config=''
+    # Extract the first word of "xml2-config", so it can be a program name with args.
+set dummy xml2-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_xml2_config+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $xml2_config in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_xml2_config="$xml2_config" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_xml2_config="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+xml2_config=$ac_cv_path_xml2_config
+if test -n "$xml2_config"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xml2_config" >&5
+$as_echo "$xml2_config" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-if test "$have_xml" = 'yes'; then
+    if test -n "$xml2_config"; then
+        # Debian installs libxml headers under /usr/include/libxml2/libxml with
+        # the shared library installed under /usr/lib, whereas the package
+        # installs itself under $prefix/libxml and $prefix/lib.
+        xml2_prefix=`xml2-config --prefix`
+        if test -d "${xml2_prefix}/include/libxml2"; then
+            CPPFLAGS="$CPPFLAGS -I${xml2_prefix}/include/libxml2"
+        fi
+        if test "${xml2_prefix}" != '/usr'; then
+            LDFLAGS="$LDFLAGS -L${xml2_prefix}/lib"
+        fi
+    fi
+    failed=0
+    passed=0
+    ac_fn_c_check_header_mongrel "$LINENO" "libxml/parser.h" "ac_cv_header_libxml_parser_h" "$ac_includes_default"
+if test "x$ac_cv_header_libxml_parser_h" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlSAXVersion in -lxml2" >&5
+$as_echo_n "checking for xmlSAXVersion in -lxml2... " >&6; }
+if ${ac_cv_lib_xml2_xmlSAXVersion+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lxml2  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char xmlSAXVersion ();
+int
+main ()
+{
+return xmlSAXVersion ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_xml2_xmlSAXVersion=yes
+else
+  ac_cv_lib_xml2_xmlSAXVersion=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_xmlSAXVersion" >&5
+$as_echo "$ac_cv_lib_xml2_xmlSAXVersion" >&6; }
+if test "x$ac_cv_lib_xml2_xmlSAXVersion" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlParseChunk in -lxml2" >&5
+$as_echo_n "checking for xmlParseChunk in -lxml2... " >&6; }
+if ${ac_cv_lib_xml2_xmlParseChunk+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lxml2  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char xmlParseChunk ();
+int
+main ()
+{
+return xmlParseChunk ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_xml2_xmlParseChunk=yes
+else
+  ac_cv_lib_xml2_xmlParseChunk=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_xmlParseChunk" >&5
+$as_echo "$ac_cv_lib_xml2_xmlParseChunk" >&6; }
+if test "x$ac_cv_lib_xml2_xmlParseChunk" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlCreatePushParserCtxt in -lxml2" >&5
+$as_echo_n "checking for xmlCreatePushParserCtxt in -lxml2... " >&6; }
+if ${ac_cv_lib_xml2_xmlCreatePushParserCtxt+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lxml2  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char xmlCreatePushParserCtxt ();
+int
+main ()
+{
+return xmlCreatePushParserCtxt ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_xml2_xmlCreatePushParserCtxt=yes
+else
+  ac_cv_lib_xml2_xmlCreatePushParserCtxt=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_xmlCreatePushParserCtxt" >&5
+$as_echo "$ac_cv_lib_xml2_xmlCreatePushParserCtxt" >&6; }
+if test "x$ac_cv_lib_xml2_xmlCreatePushParserCtxt" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if XML package is complete" >&5
+$as_echo_n "checking if XML package is complete... " >&6; }
+    if test $passed -gt 0; then
+        if test $failed -gt 0; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+$as_echo "no -- some components failed test" >&6; }
+            have_xml='no (failed tests)'
+            LDFLAGS="$PERSIST_LDFLAGS"
+            CPPFLAGS="$PERSIST_CPPFLAGS"
+        else
+            XML_LIBS='-lxml2'
+            LIBS="$XML_LIBS $LIBS"
 
 $as_echo "#define XML_DELEGATE 1" >>confdefs.h
 
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$XML_CFLAGS $CPPFLAGS"
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+            have_xml='yes'
+        fi
+    else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
     fi
 fi
-
  if test "$have_xml" = 'yes'; then
   XML_DELEGATE_TRUE=
   XML_DELEGATE_FALSE='#'
@@ -30998,7 +31466,6 @@
 
 
 
-
 # Substitute compiler name to build/link PerlMagick
 #
 
diff --git a/configure.ac b/configure.ac
index 74d3035..21d37e5 100755
--- a/configure.ac
+++ b/configure.ac
@@ -1680,7 +1680,7 @@
 #
 # Check for FFTW delegate library.
 #
-AC_ARG_WITH(fftw,
+AC_ARG_WITH([fftw],
     [AC_HELP_STRING([--without-fftw],
                     [disable FFTW support])],
     [with_fftw=$withval],
@@ -1690,22 +1690,33 @@
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fftw=$with_fftw "
 fi
 
-FFTW_PKG=""
-if test "x$with_fftw" = "xyes"; then
+have_fftw='no'
+FFTW_LIBS=''
+if test "$with_fftw" != 'no'; then
     AC_MSG_RESULT([-------------------------------------------------------------])
-    PKG_CHECK_MODULES(FFTW3,[fftw3], have_fftw=yes, have_fftw=no)
+    AC_MSG_CHECKING([for FFTW])
     AC_MSG_RESULT([])
-fi
-
-if test "$have_fftw" = 'yes'; then
-    AC_DEFINE(FFTW_DELEGATE,1,Define if you have FFTW library)
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$FFTW_CFLAGS $CPPFLAGS"
+    failed=0
+    passed=0
+    AC_CHECK_HEADER(fftw3.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+    AC_CHECK_LIB(fftw3,fftw_execute,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+    AC_MSG_CHECKING([if FFTW package is complete])
+    if test $passed -gt 0; then
+        if test $failed -gt 0; then
+            AC_MSG_RESULT([no -- some components failed test])
+            have_fftw='no (failed tests)'
+        else
+            FFTW_LIBS='-lfftw3'
+            LIBS="$FFTW_LIBS $LIBS"
+            AC_DEFINE(FFTW_DELEGATE,1,Define if you have FFTW library)
+            AC_MSG_RESULT([yes])
+            have_fftw='yes'
+        fi
+    else
+        AC_MSG_RESULT([no])
     fi
 fi
-
 AM_CONDITIONAL(FFTW_DELEGATE, test "$have_fftw" = 'yes')
-AC_SUBST(FFTW_CFLAGS)
 AC_SUBST(FFTW_LIBS)
 
 dnl ===========================================================================
@@ -1793,37 +1804,85 @@
 dnl ===========================================================================
 
 #
-# Check for FREETYPE delegate library.
+# Check for freetype delegate library.
 #
-AC_ARG_WITH(freetype,
+AC_ARG_WITH([freetype],
     [AC_HELP_STRING([--without-freetype],
-                    [disable FREETYPE support])],
+                    [disable Freetype support])],
     [with_freetype=$withval],
     [with_freetype='yes'])
 
+
 if test "$with_freetype" != 'yes'; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-freetype=$with_freetype "
 fi
 
-FREETYPE_PKG=""
-if test "x$with_freetype" = "xyes"; then
+have_freetype='no'
+FREETYPE_LIBS=''
+if test "$with_freetype" != 'no'; then
     AC_MSG_RESULT([-------------------------------------------------------------])
-    PKG_CHECK_MODULES(FREETYPE2,[freetype2], have_freetype=yes, have_freetype=no)
+    AC_MSG_CHECKING([for FreeType 2.0])
     AC_MSG_RESULT([])
-fi
+    failed=0
+    passed=0
+    PERSIST_LIBS="$LIBS"
+    PERSIST_CPPFLAGS="$CPPFLAGS"
+    if test "$enable_delegate_build" != 'no' && test -d "$builddir/freetype/include"; then
+        :
+    else
+        freetype_config=''
+        AC_CHECK_PROGS(freetype_config,freetype-config,)dnl
+        if test -n "$freetype_config"; then
+            freetype_cflags=`$freetype_config --cflags`
+            freetype_libs=`$freetype_config --libs`
+            LIBS="$LIBS $freetype_libs"
+            CPPFLAGS="$freetype_cflags $CPPFLAGS"
+        fi
+    fi
 
-if test "$have_freetype" = 'yes'; then
-    AC_DEFINE(FREETYPE_DELEGATE,1,Define if you have FREETYPE library)
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$FREETYPE_CFLAGS $CPPFLAGS"
+dnl First see if there is a library
+    if test "$FREETYPE_LIBS" = ''; then
+        AC_CHECK_LIB(freetype,FT_Init_FreeType,FREETYPE_LIBS='-lfreetype',,)
+        if test "$FREETYPE_LIBS" != ''; then
+            passed=`expr $passed + 1`
+        else
+            failed=`expr $failed + 1`
+            LIBS="$PERSIST_LIBS"
+        fi
+    fi
+
+dnl Now test for the headers
+    AC_CHECK_HEADER([ft2build.h],[FT2BUILD_H='#include <ft2build.h>'],[ft2build=''],[])
+    AC_CHECK_HEADER(freetype/freetype.h,[have_freetype_h='yes'],[have_freetype_h='no'],[$FT2BUILD_H])
+    if test "$ac_cv_header_ft2build_h" = 'yes' || test "$have_freetype_h" = 'yes'; then
+        passed=`expr $passed + 1`
+    else
+        failed=`expr $failed + 1`
+        CPPFLAGS="$PERSIST_CPPFLAGS"
+    fi
+
+    AC_MSG_CHECKING([if FreeType package is complete])
+    if test $passed -gt 0; then
+        if test $failed -gt 0; then
+            FREETYPE_LIBS=''
+            AC_MSG_RESULT([no -- some components failed test])
+            have_freetype='no (failed tests)'
+        else
+            LIBS="$FREETYPE_LIBS $LIBS"
+            AC_DEFINE(FREETYPE_DELEGATE,1,Define if you have FreeType (TrueType font) library)
+            if test "$ac_cv_header_ft2build_h" = 'yes'; then
+                AC_DEFINE([HAVE_FT2BUILD_H],[1],[Define to 1 if you have the <ft2build.h> header file.])
+            fi
+            AC_MSG_RESULT([yes])
+            have_freetype='yes'
+        fi
+    else
+        AC_MSG_RESULT([no])
     fi
 fi
-
-AM_CONDITIONAL(FREETYPE_DELEGATE, test "$have_freetype" = 'yes')
-AC_SUBST(FREETYPE_CFLAGS)
+AM_CONDITIONAL(FREETYPE_DELEGATE,test "$have_freetype" = 'yes')
 AC_SUBST(FREETYPE_LIBS)
 
-
 dnl ===========================================================================
 
 dnl ===========================================================================
@@ -2267,35 +2326,45 @@
 
 dnl ===========================================================================
 
-#
-# Check for LZMA delegate library.
-#
+# Disable LZMA (lzma library)
 AC_ARG_WITH(lzma,
-    [AC_HELP_STRING([--without-lzma],
-                    [disable LZMA support])],
-    [with_lzma=$withval],
-    [with_lzma='yes'])
-
-if test "$with_lzma" != 'yes'; then
+	      [  --without-lzma          disable LZMA support],
+	      [with_lzma=$withval],
+	      [with_lzma='yes'])
+if test "$with_lzma" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-lzma=$with_lzma "
 fi
 
-LZMA_PKG=""
-if test "x$with_lzma" = "xyes"; then
+#
+# Check for LZMA
+#
+have_lzma='no'
+LZMA_LIBS=''
+if test "$with_lzma" != 'no' || test "$with_tiff" != 'no'; then
     AC_MSG_RESULT([-------------------------------------------------------------])
-    PKG_CHECK_MODULES(LZMA,[liblzma], have_lzma=yes, have_lzma=no)
-    AC_MSG_RESULT([])
-fi
-
-if test "$have_lzma" = 'yes'; then
-    AC_DEFINE(LZMA_DELEGATE,1,Define if you have LZMA library)
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$LZMA_CFLAGS $CPPFLAGS"
+  AC_MSG_CHECKING(for LZMA)
+  AC_MSG_RESULT()
+  failed=0
+  passed=0
+  AC_CHECK_HEADER(lzma.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
+  AC_CHECK_LIB(lzma,lzma_code,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+  AC_MSG_CHECKING(if LZMA package is complete)
+  if test $passed -gt 0; then
+    if test $failed -gt 0; then
+      AC_MSG_RESULT(no -- some components failed test)
+      have_lzma='no (failed tests)'
+    else
+      LZMA_LIBS='-llzma'
+      LIBS="$LZMA_LIBS $LIBS"
+      AC_DEFINE(LZMA_DELEGATE,1,Define if you have lzma compression library)
+      AC_MSG_RESULT(yes)
+      have_lzma='yes'
     fi
+  else
+    AC_MSG_RESULT(no)
+  fi
 fi
-
 AM_CONDITIONAL(LZMA_DELEGATE, test "$have_lzma" = 'yes')
-AC_SUBST(LZMA_CFLAGS)
 AC_SUBST(LZMA_LIBS)
 
 dnl ===========================================================================
@@ -2349,24 +2418,108 @@
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-png=$with_png "
 fi
 
-PNG_PKG=""
-if test "x$with_png" = "xyes"; then
-    AC_MSG_RESULT([-------------------------------------------------------------])
-    PKG_CHECK_MODULES(PNG,[libpng], have_png=yes, have_png=no)
-    AC_MSG_RESULT([])
+have_png='no'
+PNG_LIBS=''
+
+if test "$with_png" != 'no' -a  "$have_zlib" != 'no' ; then
+  AC_MSG_RESULT([-------------------------------------------------------------])
+  AC_MSG_CHECKING(for PNG support )
+  AC_MSG_RESULT()
+  failed=0
+  passed=0
+  AC_CHECK_HEADER(png.h,passed=`expr $passed + 1`,
+     failed=`expr $failed + 1`,)
+
+  if test $passed -gt 0; then
+    for var in 5 4 2 '' ; do
+      if test "$have_png" == 'no' ; then
+        if test "x${var}" == 'x' ; then
+          pnglib='png'
+        else
+          pnglib="png1${var}"
+        fi
+
+#       Test for compatible LIBPNG library
+        failed=0
+        passed=0
+        if test "$with_png" == 'yes' -o "$with_png" == "libpng1${var}" ; then
+          if test "${pnglib}" != 'png' ; then
+            AC_MSG_CHECKING(for LIBPNG1${var} support )
+            AC_TRY_COMPILE(
+#include <stdio.h>
+#include <stdlib.h>
+#include <png.h>
+,
+changequote(<<, >>)dnl
+<<
+#if PNG_LIBPNG_VER_MINOR != ${var}
+#error LIBPNG library must be version 1${var}!
+Kaboom, Kaboom
+#endif
+return 0;
+>>,
+            changequote([, ])dnl
+            ac_cv_libpng_ok='yes',
+            ac_cv_libpng_ok='no')
+            if test "$ac_cv_libpng_ok" = 'yes' ; then
+              passed=`expr $passed + 1`
+              AC_MSG_RESULT(yes)
+            else
+              failed=`expr $failed + 1`
+              AC_MSG_RESULT(no)
+            fi
+          else
+            passed=`expr $passed + 1`
+            AC_MSG_RESULT(yes)
+          fi
+        fi
+
+        if test $passed -gt 0 -a $failed -le 0; then
+          if test "1${var}" = '15' ; then
+            AC_CHECK_LIB(png15,png_get_io_ptr,passed=`expr $passed + 1`,
+               failed=`expr $failed + 1`,)
+            AC_CHECK_LIB(png15,png_longjmp,passed=`expr $passed + 1`,
+               failed=`expr $failed + 1`,)
+          fi
+          if test "1${var}" = '14' ; then
+            AC_CHECK_LIB(png14,png_get_io_ptr,passed=`expr $passed + 1`,
+               failed=`expr $failed + 1`,)
+            AC_CHECK_LIB(png14,png_get_io_state,passed=`expr $passed + 1`,
+               failed=`expr $failed + 1`,)
+          fi
+          if test "1${var}" = '12' ; then
+            AC_CHECK_LIB(png12,png_get_io_ptr,passed=`expr $passed + 1`,
+               failed=`expr $failed + 1`,)
+          fi
+          if test "1${var}" = '1' ; then
+              AC_CHECK_LIB(png,png_get_io_ptr,passed=`expr $passed + 1`,
+                 failed=`expr $failed + 1`,)
+          fi
+          if test $passed -gt 0 -a $failed -le 0 ; then
+            AC_MSG_CHECKING(if ${pnglib} package is complete)
+            if test $passed -gt 0 ; then
+              if test $failed -gt 0 ; then
+                  AC_MSG_RESULT(no -- some components failed test)
+                  have_png='no (failed tests)'
+              else
+                  PNG_LIBS="-l${pnglib}"
+                  LIBS="$PNG_LIBS $LIBS"
+                  AC_DEFINE(PNG_DELEGATE,1,Define if you have PNG library)
+                  AC_MSG_RESULT(yes)
+                  have_png='yes'
+              fi
+            fi
+          fi
+        fi
+      fi
+    done
+  fi
 fi
 
-if test "$have_png" = 'yes'; then
-    AC_DEFINE(PNG_DELEGATE,1,Define if you have PNG library)
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$PNG_CFLAGS $CPPFLAGS"
-    fi
-fi
-
-AM_CONDITIONAL(PNG_DELEGATE, test "$have_png" = 'yes')
-AC_SUBST(PNG_CFLAGS)
+AM_CONDITIONAL(PNG_DELEGATE,test "$have_png" = 'yes')
 AC_SUBST(PNG_LIBS)
 
+
 dnl ===========================================================================
 
 #
@@ -2572,35 +2725,69 @@
 
 dnl ===========================================================================
 
+
+dnl ===========================================================================
+
 #
 # Check for XML delegate library.
 #
-AC_ARG_WITH(xml,
+AC_ARG_WITH([xml],
     [AC_HELP_STRING([--without-xml],
                     [disable XML support])],
     [with_xml=$withval],
-    [with_xml='yes'])
+    [with_xml=$have_x])
 
-if test "$with_xml" != 'yes'; then
+if test "$with_xml" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-xml=$with_xml "
 fi
 
-XML_PKG=""
-if test "x$with_xml" = "xyes"; then
+have_xml='no'
+XML_LIBS=''
+if test "$with_xml" != 'no'; then
     AC_MSG_RESULT([-------------------------------------------------------------])
-    PKG_CHECK_MODULES(XML2,[libxml-2.0], have_xml=yes, have_xml=no)
+    AC_MSG_CHECKING([for XML])
     AC_MSG_RESULT([])
-fi
-
-if test "$have_xml" = 'yes'; then
-    AC_DEFINE(XML_DELEGATE,1,Define if you have XML library)
-    if test "$with_modules" = 'no'; then
-        CPPFLAGS="$XML_CFLAGS $CPPFLAGS"
+    PERSIST_LDFLAGS=$LDFLAGS
+    PERSIST_CPPFLAGS=$CPPFLAGS
+    xml2_config=''
+    AC_PATH_PROG(xml2_config,xml2-config,)dnl
+    if test -n "$xml2_config"; then
+        # Debian installs libxml headers under /usr/include/libxml2/libxml with
+        # the shared library installed under /usr/lib, whereas the package
+        # installs itself under $prefix/libxml and $prefix/lib.
+        xml2_prefix=`xml2-config --prefix`
+        if test -d "${xml2_prefix}/include/libxml2"; then
+            CPPFLAGS="$CPPFLAGS -I${xml2_prefix}/include/libxml2"
+        fi
+        if test "${xml2_prefix}" != '/usr'; then
+            LDFLAGS="$LDFLAGS -L${xml2_prefix}/lib"
+        fi
+    fi
+    failed=0
+    passed=0
+    AC_CHECK_HEADER(libxml/parser.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
+    AC_CHECK_LIB(xml2,xmlSAXVersion,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+    AC_CHECK_LIB(xml2,xmlParseChunk,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+    AC_CHECK_LIB(xml2,xmlCreatePushParserCtxt,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+    AC_MSG_CHECKING([if XML package is complete])
+    if test $passed -gt 0; then
+        if test $failed -gt 0; then
+            AC_MSG_RESULT([no -- some components failed test])
+            have_xml='no (failed tests)'
+            LDFLAGS="$PERSIST_LDFLAGS"
+            CPPFLAGS="$PERSIST_CPPFLAGS"
+        else
+            XML_LIBS='-lxml2'
+            LIBS="$XML_LIBS $LIBS"
+            AC_DEFINE(XML_DELEGATE,1,Define if you have XML library)
+            AC_MSG_RESULT([yes])
+            have_xml='yes'
+        fi
+    else
+        AC_MSG_RESULT([no])
     fi
 fi
-
-AM_CONDITIONAL(XML_DELEGATE, test "$have_xml" = 'yes')
-AC_SUBST(XML_CFLAGS)
+AM_CONDITIONAL(XML_DELEGATE,test "$have_xml" = 'yes')
 AC_SUBST(XML_LIBS)
 
 dnl ===========================================================================