dnl Process this file with autoconf to produce a configure script.

AC_INIT(include/xmlrpc-c/base.h)
AC_CONFIG_HEADERS(xmlrpc_amconfig.h)

dnl =======================================================================
dnl Define PACKAGE, VERSION, @PACKAGE@, @VERSION@
dnl =======================================================================

dnl Increment the package version for each release.
AM_INIT_AUTOMAKE(xmlrpc-c, 1.03.13)

dnl This version number needs to be changed in several *different* tricky
dnl ways for each release. Please read the libtool documentation very
dnl closely before touching this or making a release!
VERSION_INFO="-version-info 7:0:4"
AC_SUBST(VERSION_INFO)

dnl Get our host type.
AC_CANONICAL_HOST
XMLRPC_HOST_TYPE=$host
AC_SUBST(XMLRPC_HOST_TYPE)

dnl We need this to compensate for an incompatibility between autoconf
dnl and our libtool.  autoconf generates an invalid ltconfig command
dnl otherwise.
test -z "$target" && target=NONE

dnl =======================================================================
dnl Decide What To Build
dnl =======================================================================

FEATURE_LIST=

AC_ARG_ENABLE(wininet-client,
  [  --disable-wininet-client  Don't build the Wininet client transport], , 
enable_wininet_client=maybe)

if test $enable_wininet_client = maybe; then
  AC_CHECK_PROG(have_wininet_config, wininet-config, yes, no)
  if test $have_wininet_config = no; then
    AC_MSG_NOTICE([You don't appear to have Wininet installed (no working wininet-config in your command search path), so we will not build the Wininet client XML transport])
    MUST_BUILD_WININET_CLIENT=no
  else
    MUST_BUILD_WININET_CLIENT=yes
  fi
else
  MUST_BUILD_WININET_CLIENT=$enable_wininet_client
fi

AC_MSG_CHECKING(whether to build Wininet client XML transport module)
AC_MSG_RESULT($MUST_BUILD_WININET_CLIENT)
AC_SUBST(MUST_BUILD_WININET_CLIENT)


AC_ARG_ENABLE(curl-client,
  [  --disable-curl-client     Don't build the Curl client transport], , 
enable_curl_client=maybe)

if test $enable_curl_client = maybe; then
  AC_CHECK_PROG(have_curl_config, curl-config, yes, no)
  if test $have_curl_config = no; then
    AC_MSG_NOTICE([You don't appear to have Curl installed (no working curl-config in your command search path), so we will not build the Curl client XML transport])
    MUST_BUILD_CURL_CLIENT=no
  else
    MUST_BUILD_CURL_CLIENT=yes
  fi
else
  MUST_BUILD_CURL_CLIENT=$enable_curl_client
fi

AC_MSG_CHECKING(whether to build Curl client XML transport module)
AC_MSG_RESULT($MUST_BUILD_CURL_CLIENT)
AC_SUBST(MUST_BUILD_CURL_CLIENT)


AC_ARG_ENABLE(libwww-client,
  [  --disable-libwww-client   Don't build the Libwww client transport], , 
enable_libwww_client=maybe)

if test $enable_libwww_client = maybe; then
  AC_CHECK_PROG(have_libwww_config, libwww-config, yes, no)
  if test $have_libwww_config = no; then
    AC_MSG_NOTICE([You don't appear to have Libwww installed (no working libwww-config in your command search path), so we will not build the Libwww client XML transport])
    MUST_BUILD_LIBWWW_CLIENT=no
  else
    MUST_BUILD_LIBWWW_CLIENT=yes
  fi
else
  MUST_BUILD_LIBWWW_CLIENT=$enable_libwww_client
fi

AC_MSG_CHECKING(whether to build Libwww client XML transport module)
AC_MSG_RESULT($MUST_BUILD_LIBWWW_CLIENT)
AC_SUBST(MUST_BUILD_LIBWWW_CLIENT)


if test "$MUST_BUILD_WININET_CLIENT $MUST_BUILD_CURL_CLIENT $MUST_BUILD_LIBWWW_CLIENT" = "no no no"; then
  AC_MSG_NOTICE([We are not building any client XML transport, therefore we will not build the client library at all.])
fi


dnl Set up the appropriate Makefile substitutions.

LIBXMLRPC_CLIENT_LA=libxmlrpc_client.la
AC_SUBST(LIBXMLRPC_CLIENT_LA)
CLIENTTEST=clienttest
AC_SUBST(CLIENTTEST)
XMLRPC_CLIENT_H=xmlrpc_client.h
AC_SUBST(XMLRPC_CLIENT_H)
XMLRPC_TRANSPORT_H=xmlrpc_transport.h
AC_SUBST(XMLRPC_TRANSPORT_H)
SYNCH_CLIENT=synch_client
AC_SUBST(SYNCH_CLIENT)
ASYNCH_CLIENT=asynch_client
AC_SUBST(ASYNCH_CLIENT)
AUTH_CLIENT=auth_client
AC_SUBST(AUTH_CLIENT)
QUERY_MEERKAT=query-meerkat
AC_SUBST(QUERY_MEERKAT)

if test $MUST_BUILD_WININET_CLIENT = yes; then
    FEATURE_LIST="wininet-client $FEATURE_LIST"
fi
if test $MUST_BUILD_CURL_CLIENT = yes; then
    FEATURE_LIST="curl-client $FEATURE_LIST"
fi
if test $MUST_BUILD_LIBWWW_CLIENT = yes; then
    FEATURE_LIST="libwww-client $FEATURE_LIST"
fi

dnl Check to see if we should build our Abyss server module.
AC_MSG_CHECKING(whether to build Abyss server module)
AC_ARG_ENABLE(abyss-server,
  [  --disable-abyss-server    Don't build the Abyss server module], ,
enable_abyss_server=yes)
AC_MSG_RESULT($enable_abyss_server)
ENABLE_ABYSS_SERVER=$enable_abyss_server
AC_SUBST(ENABLE_ABYSS_SERVER)

dnl Set up the appropriate Makefile substitutions.
ABYSS_SUBDIR=
LIBXMLRPC_ABYSS_SERVER_LA=
SERVERTEST=
VALIDATEE=
XMLRPC_ABYSS_H=
SERVER=
if test x"$enable_abyss_server" != xno; then
    FEATURE_LIST="abyss-server $FEATURE_LIST"
    ABYSS_SUBDIR=abyss
    LIBXMLRPC_ABYSS_SERVER_LA=libxmlrpc_abyss_server.la
    SERVERTEST=servertest
    VALIDATEE=validatee
    XMLRPC_ABYSS_H=xmlrpc_abyss.h
    SERVER=server
fi
AC_SUBST(ABYSS_SUBDIR)
AC_SUBST(LIBXMLRPC_ABYSS_SERVER_LA)
AC_SUBST(SERVERTEST)
AC_SUBST(VALIDATEE)
AC_SUBST(XMLRPC_ABYSS_H)
AC_SUBST(SERVER)

dnl Check to see if we should build our CGI server module.
AC_MSG_CHECKING(whether to build CGI server module)
AC_ARG_ENABLE(cgi-server,
  [  --disable-cgi-server      Don't build the CGI server module], ,
enable_cgi_server=yes)
AC_MSG_RESULT($enable_cgi_server)
ENABLE_CGI_SERVER=$enable_cgi_server
AC_SUBST(ENABLE_CGI_SERVER)

dnl Check to see if we should build our C++ stuff.
AC_MSG_CHECKING(whether to build C++ wrappers and tools)
AC_ARG_ENABLE(cplusplus,
  [  --disable-cplusplus       Don't build the C++ wrapper classes or tools], ,
enable_cplusplus=yes)
AC_MSG_RESULT($enable_cplusplus)
ENABLE_CPLUSPLUS=$enable_cplusplus
AC_SUBST(ENABLE_CPLUSPLUS)

dnl Set up the appropriate Makefile substitutions.
LIBXMLRPC_CPP_A=
CPPTEST=
XMLRPCCPP_H=
XML_RPC_API2CPP_SUBDIR=
MEERKAT_APP_LIST=
INTEROP_CLIENT_SUBDIR=
if test x"$enable_cplusplus" != xno; then
    FEATURE_LIST="c++ $FEATURE_LIST"
    LIBXMLRPC_CPP_A=libxmlrpc_cpp.a
    CPPTEST=cpptest
    XMLRPCCPP_H=XmlRpcCpp.h

    if test $MUST_BUILD_LIBWWW_CLIENT = yes; then
        XML_RPC_API2CPP_SUBDIR=xml-rpc-api2cpp
    elif test $MUST_BUILD_CURL_CLIENT = yes; then
        XML_RPC_API2CPP_SUBDIR=xml-rpc-api2cpp
    fi
fi
AC_SUBST(LIBXMLRPC_CPP_A)
AC_SUBST(CPPTEST)
AC_SUBST(XMLRPCCPP_H)
AC_SUBST(XML_RPC_API2CPP_SUBDIR)

dnl =======================================================================
dnl Decide what to do about Unicode.
dnl =======================================================================

dnl Check to see if we should build our Unicode stuff.
AC_MSG_CHECKING(whether to build Unicode support)
AC_ARG_ENABLE(unicode,
  [  --disable-unicode         Don't build Unicode and wchar_t capability], ,
enable_unicode=yes)
AC_MSG_RESULT($enable_unicode)

dnl Do all the work...
if test x"$enable_unicode" != xno; then
    FEATURE_LIST="unicode $FEATURE_LIST"
    HAVE_UNICODE_WCHAR_DEFINE=1

    dnl Unicode function needed by test suites.
    AC_CHECK_FUNCS(wcsncmp)

    AC_CHECK_HEADERS(wchar.h, , [
    AC_MSG_ERROR(wchar.h is required to build this library)
    ])

else
    HAVE_UNICODE_WCHAR_DEFINE=0
fi

AC_SUBST(HAVE_UNICODE_WCHAR_DEFINE)

AC_SUBST(FEATURE_LIST)


dnl =======================================================================
dnl Checks for programs.
dnl =======================================================================

AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL


dnl =======================================================================
dnl Checks for libraries.
dnl =======================================================================

# Code by albert chin <china@thewrittenword.com> to check for various
# oddball networking libraries.  Solaris and some other operating systems
# hide their networking code in various places.  (Yes, this links too many
# of our libraries against -lsocket, but a finer-grained mechanism would
# require too much testing.)
AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))

# For some reason, we don't seem to need this on Solaris.  If you do
# need it, go ahead and try it.
# AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))


dnl =======================================================================
dnl Checks for header files.
dnl =======================================================================

AC_STDC_HEADERS

AC_CHECK_HEADERS(stdarg.h, , [
AC_MSG_ERROR(stdarg.h is required to build this library)
])

# I/O headers, needed by Abyss on Solaris.
AC_CHECK_HEADERS(sys/filio.h sys/ioctl.h)


dnl =======================================================================
dnl Checks for typedefs, structures, and compiler characteristics.
dnl =======================================================================

dnl AC_C_BIGENDIAN
AC_TYPE_SIZE_T

dnl This check is borrowed from Python 1.5.2.
va_list_is_array=no
AC_MSG_CHECKING(whether va_list is an array)
AC_TRY_COMPILE([
#include <stdarg.h>
], [va_list list1, list2; list1 = list2;], , 
va_list_is_array=yes)
AC_MSG_RESULT($va_list_is_array)
if test x"$va_list_is_array" = xyes; then
  VA_LIST_IS_ARRAY_DEFINE=1
else
  VA_LIST_IS_ARRAY_DEFINE=0
fi
AC_SUBST(VA_LIST_IS_ARRAY_DEFINE)

dnl See if the compiler supports __attribute__ gracefully.
AC_MSG_CHECKING(whether compiler supports __attribute__)
AC_TRY_COMPILE(, [int x __attribute__((__unused__));],
compiler_supports_attribute=yes,
compiler_supports_attribute=no)
AC_MSG_RESULT($compiler_supports_attribute)
if test x"$compiler_supports_attribute" = xyes; then
    ATTR_UNUSED="__attribute__((__unused__))"
else
    ATTR_UNUSED=
fi
AC_SUBST(ATTR_UNUSED)


dnl =======================================================================
dnl Checks for library functions.
dnl =======================================================================

AC_CHECK_FUNC(vsnprintf, , [
AC_MSG_ERROR(your C library does not provide vsnprintf)
])

dnl CygWin looks like Unix, but doesn't provide setgroups.
AC_CHECK_FUNCS(setgroups)

AC_CHECK_FUNCS(asprintf)

AC_CHECK_FUNCS(setenv)


dnl =======================================================================
dnl Checks for operating system features.
dnl =======================================================================

dnl Non-Unix systems will need to set up their platform configuration file
dnl by hand.
DIRECTORY_SEPARATOR="/"
AC_SUBST(DIRECTORY_SEPARATOR)


dnl =======================================================================
dnl ABYSS Configuration
dnl =======================================================================
dnl Abyss doesn't pay any attention to xmlrpc_config.h, so we need to
dnl pass it some flags on the command-line.

AC_MSG_CHECKING(whether to use Abyss pthread function)
AC_ARG_ENABLE(abyss-threads,
  [  --disable-abyss-threads   Use fork in Abyss instead of pthreads], ,
  enable_abyss_threads=yes)
AC_MSG_RESULT($enable_abyss_threads)

ENABLE_ABYSS_THREADS=$enable_abyss_threads
AC_SUBST(ENABLE_ABYSS_THREADS)

if test x"$enable_abyss_threads" != xno; then
    CFLAGS="$CFLAGS -D_THREAD"
    LIBABYSS_LDADD="-lpthread"
fi
AC_SUBST(LIBABYSS_LDADD)


dnl =======================================================================
dnl Finding wininet stubs
dnl =======================================================================
dnl If you implement the parts of wininet.h the wininet_transport uses,
dnl you will need to configure this way..

if test $MUST_BUILD_WININET_CLIENT = yes; then

    dnl You can control which of these gets chosen by fooling around with PATH.
    AC_PATH_PROGS(WININET_CONFIG, wininet-xmlrpc-config wininet-config, no)
    if test "x$WININET_CONFIG" = "xno"; then
        AC_MSG_ERROR(wininet lib not found; see './configure --help')
    fi

    dnl Get our wininet version.
    dnl Adapted from a macro which called gtk-config.
    AC_MSG_CHECKING(for wininet version >= 1.0.0)
    W3VER=`$WININET_CONFIG --version`
    WININET_MAJOR=\
`echo $W3VER|sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
    WININET_MINOR=\
`echo $W3VER|sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
    WININET_MICRO=\
`echo $W3VER|sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
    AC_MSG_RESULT($WININET_MAJOR.$WININET_MINOR.$WININET_MICRO)

    dnl Check to make sure our version is OK.
    WININET_VERSION_OK=yes
    if test $WININET_MAJOR -lt 1; then
        WININET_VERSION_OK=no
    else
        if test $WININET_MAJOR -eq 1 -a $WININET_MINOR -lt 0; then
            WININET_VERSION_OK=no
        else
            if test $WININET_MAJOR -eq 1 -a $WININET_MINOR -eq 0 \
                -a $WININET_MICRO -lt 0; then
                WININET_VERSION_OK=no
            fi
        fi
    fi
    if test "x$WININET_VERSION_OK" = "xno"; then
        AC_MSG_ERROR(wininet version >= 1.0.0 required)
    fi

    dnl Get the necessary CFLAGS, and merge them into our master list.
    WININET_CFLAGS="`$WININET_CONFIG --cflags`"
    AC_SUBST(WININET_CFLAGS)
    CFLAGS="$CFLAGS $WININET_CFLAGS" 

    dnl Get the huge list of libraries we need to link against.
    WININET_LDADD="`$WININET_CONFIG --libs`"
    AC_SUBST(WININET_LDADD)

    dnl Oh, such massive brain damage! Because there may be another copy
    dnl of libwww in the default dynamic loader search path, we need to
    dnl adjust the search patch manually. Just gag me with a backquote, OK?
    AC_MSG_CHECKING(for wininet library directory)
    if $WININET_CONFIG --rpath-dir > /dev/null 2>&1; then
       dnl Yay! We're using our smart version of wininet.
       WININET_LIBDIR="`$WININET_CONFIG --rpath-dir`"
    else
       dnl Yawn. We're using the regular boring version.
       WININET_LIBDIR="`$WININET_CONFIG --prefix`/lib"
    fi
    AC_MSG_RESULT($WININET_LIBDIR)
    AC_SUBST(WININET_LIBDIR)
    WININET_RPATH="-rpath $WININET_LIBDIR"
    AC_SUBST(WININET_RPATH)
    WININET_WL_RPATH="-Wl,--rpath -Wl,$WININET_LIBDIR"
    AC_SUBST(WININET_WL_RPATH)

fi # MUST_BUILD_WININET_CLIENT

dnl =======================================================================
dnl Finding w3c-libwww
dnl =======================================================================
dnl Once upon a time, we used a patched copy of libwww that needed to
dnl co-exist with the system copy of libwww. We have some vestigal support
dnl for keeping track of libwww's rpath, although this is no longer really
dnl necessary.

if test $MUST_BUILD_LIBWWW_CLIENT = yes; then

    dnl First of all, locate the semi-broken libwww config program.
    dnl You can control which of these gets chosen by fooling around with PATH.
    AC_PATH_PROGS(LIBWWW_CONFIG, libwww-xmlrpc-config libwww-config, no)
    if test "x$LIBWWW_CONFIG" = "xno"; then
        AC_MSG_ERROR(w3c-libwww not found; see './configure --help')
    fi

    dnl Get our libwww version.
    dnl Adapted from a macro which called gtk-config.
    AC_MSG_CHECKING(for w3c-libwww version >= 5.2.8)
    W3VER=`$LIBWWW_CONFIG --version`
    LIBWWW_MAJOR=\
`echo $W3VER|sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
    LIBWWW_MINOR=\
`echo $W3VER|sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
    LIBWWW_MICRO=\
`echo $W3VER|sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
    AC_MSG_RESULT($LIBWWW_MAJOR.$LIBWWW_MINOR.$LIBWWW_MICRO)

    dnl Check to make sure our version is OK.
    LIBWWW_VERSION_OK=yes
    if test $LIBWWW_MAJOR -lt 5; then
        LIBWWW_VERSION_OK=no
    else
        if test $LIBWWW_MAJOR -eq 5 -a $LIBWWW_MINOR -lt 2; then
            LIBWWW_VERSION_OK=no
        else
            if test $LIBWWW_MAJOR -eq 5 -a $LIBWWW_MINOR -eq 2 \
                -a $LIBWWW_MICRO -lt 8; then
                LIBWWW_VERSION_OK=no
            fi
        fi
    fi
    if test "x$LIBWWW_VERSION_OK" = "xno"; then
        AC_MSG_ERROR(w3c-libwww version >= 5.2.8 required)
    fi

    dnl Get the huge list of libraries we need to link against.
    LIBWWW_LDADD="`$LIBWWW_CONFIG --libs`"
    AC_SUBST(LIBWWW_LDADD)

    dnl Oh, such massive brain damage! Because there may be another copy
    dnl of libwww in the default dynamic loader search path, we need to
    dnl adjust the search patch manually. Just gag me with a backquote, OK?
    AC_MSG_CHECKING(for libwww library directory)
    if $LIBWWW_CONFIG --rpath-dir > /dev/null 2>&1; then
       dnl Yay! We're using our smart version of libwww.
       LIBWWW_LIBDIR="`$LIBWWW_CONFIG --rpath-dir`"
    else
       dnl Yawn. We're using the regular boring version.
       LIBWWW_LIBDIR="`$LIBWWW_CONFIG --prefix`/lib"
    fi
    AC_MSG_RESULT($LIBWWW_LIBDIR)
    AC_SUBST(LIBWWW_LIBDIR)

    # Some ancient rpath stuff, now disabled.  I turned this off because it
    # breaks Debian (and Mandrake?) policy, and we don't use it anymore.
    # If you have multiple copies of w3c-libwww lying around, you can turn
    # it back on.
    #LIBWWW_RPATH="-rpath $LIBWWW_LIBDIR"
    LIBWWW_RPATH=""
    AC_SUBST(LIBWWW_RPATH)
    #LIBWWW_WL_RPATH="-Wl,--rpath -Wl,$LIBWWW_LIBDIR"
    LIBWWW_WL_RPATH=""
    AC_SUBST(LIBWWW_WL_RPATH)

fi # MUST_BUILD_LIBWWW_CLIENT


dnl =======================================================================
dnl Finding cURL
dnl =======================================================================

if test $MUST_BUILD_CURL_CLIENT = yes; then

    dnl First of all, locate the curl config program.
    dnl You can control which of these gets chosen by fooling around with PATH.
    AC_PATH_PROGS(CURL_CONFIG, curl-xmlrpc-config curl-config, no)
    if test "x$CURL_CONFIG" = "xno"; then
        AC_MSG_ERROR(cURL not found; see './configure --help')
    fi
    
    dnl There used to be code here to check the Curl version and make sure
    dnl it is at least 7.8.  But there were bugs both in the code and in 
    dnl curl (curl-config --vernum, at least in older versios of Curl,
    dnl omits the leading zero).  So it didn't work.  Plus, checking version
    dnl numbers isn't a good idea.  Better to check for feature presence.
    dnl So we don't do any check now.  If we find out there's a problem with
    dnl older Curls, we will revisit that.

    dnl Get the huge list of libraries we need to link against.
    dnl MRB-20010516-For some reason, curl-config
    dnl does not list itself '-lcurl'.  2004.12.12.  It seems to do so
    dnl now.
    CURL_LDADD=`$CURL_CONFIG --libs`
    AC_SUBST(CURL_LDADD)

    dnl Oh, such massive brain damage! Because there may be another copy
    dnl of curl in the default dynamic loader search path, we need to
    dnl adjust the search patch manually. Just gag me with a backquote, OK?
    AC_MSG_CHECKING(for curl library directory)
    dnl Yawn. We're using the regular boring version.
    CURL_LIBDIR="`$CURL_CONFIG --prefix`/lib"

    AC_MSG_RESULT($CURL_LIBDIR)
    AC_SUBST(CURL_LIBDIR)
    CURL_RPATH="-rpath $CURL_LIBDIR"
    AC_SUBST(CURL_RPATH)
    CURL_WL_RPATH="-Wl,--rpath -Wl,$CURL_LIBDIR"
    AC_SUBST(CURL_WL_RPATH)

fi # MUST_BUILD_CURL_CLIENT


dnl =======================================================================
dnl Checks for build options.
dnl =======================================================================

AC_ARG_WITH(libwww-ssl,
  [  --with-libwww-ssl       Include libwww SSL capability.]
   ) 

if test x"$enable_libwww_client" != xno; then
    AC_MSG_CHECKING(whether to use SSL with libwww)
    if test x"$with_libwww_ssl" = xyes; then
        AC_MSG_RESULT(yes)
        HAVE_LIBWWW_SSL_DEFINE=1
    else
        AC_MSG_RESULT(no)
        HAVE_LIBWWW_SSL_DEFINE=0
    fi
fi
AC_SUBST(HAVE_LIBWWW_SSL_DEFINE)

dnl Check to see if we should build the libxml2 backend.
AC_ARG_ENABLE(libxml2-backend,
  [  --enable-libxml2-backend  Use libxml2 instead of built-in expat], ,
enable_libxml2_backend=no)
AC_MSG_CHECKING(whether to build the libxml2 backend)
AC_MSG_RESULT($enable_libxml2_backend)
ENABLE_LIBXML2_BACKEND=$enable_libxml2_backend
AC_SUBST(ENABLE_LIBXML2_BACKEND)

dnl If we're using the libxml2 backend, look for pkg-config
if test x"$enable_libxml2_backend" != xno; then
    AC_MSG_CHECKING(for pkg-config)
    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
    if test x$PKG_CONFIG = xno; then
        AC_MSG_ERROR([*** pkg-config not found.  See http://www.freedesktop.org/software/pkgconfig/])
    fi

dnl Set up the appropriate Makefile substitutions
    LIBXML2_CFLAGS=`pkg-config --cflags libxml-2.0`
    AC_SUBST(LIBXML2_CFLAGS)
    CFLAGS="$CFLAGS $LIBXML2_CFLAGS"

    LIBXML2_LIBS=`pkg-config --libs libxml-2.0`
    AC_SUBST(LIBXML2_LIBS)

    EXTRA_XML_LIBS="$LIBXML2_LIBS"
else
    EXTRA_XML_LIBS="-lxmlrpc_xmlparse -lxmlrpc_xmltok"
fi

AC_SUBST(EXTRA_XML_LIBS)

AC_MSG_CHECKING(whether to test with Electric Fence)
AC_ARG_ENABLE(efence,
  [  --enable-efence           Enable malloc/free debugging with Bruce Perens\'
                              Electric Fence library (test suites only).])
AC_MSG_RESULT($enable_efence)
ENABLE_EFENCE=$enable_efence
AC_SUBST(ENABLE_EFENCE)

dnl =======================================================================
dnl Compiler information
dnl =======================================================================
C_COMPILER_GNU=$ac_cv_c_compiler_gnu
AC_SUBST(C_COMPILER_GNU)
CXX_COMPILER_GNU=$ac_cv_cxx_compiler_gnu
AC_SUBST(CXX_COMPILER_GNU)

dnl obsolete variables, need to be removed from Makefile.in:
CC_WARN_FLAGS=
AC_SUBST(CC_WARN_FLAGS)
CPP_WARN_FLAGS=
AC_SUBST(CPP_WARN_FLAGS)


BUILDDIR=`pwd`
AC_SUBST(BUILDDIR)



AC_DEFUN([AX_COMPILER_VENDOR],
[
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
 [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
  # note: don't check for gcc first since some other compilers define __GNUC__
  for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
    vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
#if !($vencpp)
      thisisanerror;
#endif
])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
  done
 ])
])

AX_COMPILER_VENDOR

#  Enable 64 bit build
AC_ARG_ENABLE(64,
[AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"])

if test "x${ax_cv_c_compiler_vendor}"  =  "xsun" ; then
    if test "${enable_64}" = "yes"; then
        COMPILER_CFLAGS=-m64
        COMPILER_CXXFLAGS=-m64
    fi
fi

AC_SUBST(COMPILER_CFLAGS)
AC_SUBST(COMPILER_CXXFLAGS)

dnl =======================================================================
dnl Libtool
dnl =======================================================================
AM_PROG_LIBTOOL


dnl =======================================================================
dnl Output our results.
dnl =======================================================================

AC_OUTPUT(xmlrpc-c-config \
          xmlrpc-c-config.test \
          Makefile.config \
          xmlrpc_config.h \
          lib/expat/Makefile \
          lib/expat/xmlparse/Makefile \
          lib/expat/xmlwf/Makefile \
          lib/expat/sample/Makefile \
          )
chmod +x xmlrpc-c-config
chmod +x xmlrpc-c-config.test