+dnl
+dnl test for libxml2
+dnl
+AC_ARG_WITH(libxml2, --with-libxml=<directory> libxml2 installed in <directory>,[
+if test $withval != yes
+then
+ dir=$withval
+else
+ dir="/usr/local"
+fi])
+
+libxmldir=""
+AC_MSG_CHECKING(for LIBXML2 files)
+for d in $dir/bin /usr/bin /usr/local/bin /usr/local/libxml2/bin /opt/libxml2/bin /opt/packages/libxml2/bin
+do
+ if test -x $d/xml2-config
+ then
+ AC_MSG_RESULT(found xml2-config in $d)
+ libxmldir=$d
+ break
+ fi
+done
+
+if test x$libxmldir = x
+then
+ AC_MSG_ERROR(xml2-config not found)
+else
+ XMLINCLUDES=`$libxmldir/xml2-config --cflags`
+ AC_SUBST(XMLINCLUDES)
+
+ XMLLIBS=`$libxmldir/xml2-config --libs`
+ AC_SUBST(XMLLIBS)
+fi
+
+dnl
+dnl check for zookeeper library
+dnl
+zkdir="/usr/local/lib"
+
+AC_ARG_WITH(zookeeper, --with-zookeeperlib=<directory> zookeeper shared object located in <directory>,[
+if test $withval = no
+then
+ zkdir=no
+ AC_MSG_WARN(Building without zookeeper support.)
+else
+ zkdir=$withval
+fi])
+
+zklib=""
+if test $zkdir != no
+then
+ AC_MSG_CHECKING(for zookeeper libraries)
+ for d in $zkdir /usr/local/lib /lib /usr/lib
+ do
+ if test -f $d/libzookeeper_mt.so
+ then
+ AC_MSG_RESULT(found libzookeeper_mt.so in $d)
+ zklib=$d/libzookeeper_mt.so
+ break
+ fi
+ done
+
+ if test x$zklib = x
+ then
+ dnl no zklib
+ AC_MSG_WARN(Zookeeper libraries not found.)
+ ZKLIBS=""
+ AC_SUBST(ZKLIBS)
+
+ ZKFLAGS=""
+ AC_SUBST(ZKFLAGS)
+ else
+ dnl found it
+ ZKLIBS=$zklib
+ AC_SUBST(ZKLIBS)
+
+ ZKFLAGS="-DTHREADED -DBUILD_ZOOKEEPER"
+ AC_SUBST(ZKFLAGS)
+ fi
+fi