-# Check whether --with-libxml2 or --without-libxml2 was given.
-if test "${with_libxml2+set}" = set; then
- withval="$with_libxml2"
- LDFLAGS=$LDFLAGS" -L"$withval"/lib";
- CPPFLAGS=$CPPFLAGS" -I"$withval"/include/libxml2"
-fi;
+# Extract the first word of "xml2-config", so it can be a program name with args.
+set dummy xml2-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_XML2CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$XML2CONFIG"; then
+ ac_cv_prog_XML2CONFIG="$XML2CONFIG" # 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 $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_XML2CONFIG=""xml2-config""
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_prog_XML2CONFIG" && ac_cv_prog_XML2CONFIG=""echo""
+fi
+fi
+XML2CONFIG=$ac_cv_prog_XML2CONFIG
+if test -n "$XML2CONFIG"; then
+ echo "$as_me:$LINENO: result: $XML2CONFIG" >&5
+echo "${ECHO_T}$XML2CONFIG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "$XML2CONFIG" != "xml2-config"; then
+ { { echo "$as_me:$LINENO: error: xml2-config for detecting libxml2 not found" >&5
+echo "$as_me: error: xml2-config for detecting libxml2 not found" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+LDFLAGS=$LDFLAGS" -L/usr/lib `$XML2CONFIG --libs`";
+CPPFLAGS=$CPPFLAGS" `$XML2CONFIG --cflags`";