jorton 8e7e0a
--- apr-util-1.2.8/xml/apr_xml.c.autoexpat
jorton 8e7e0a
+++ apr-util-1.2.8/xml/apr_xml.c
jorton 8e7e0a
@@ -25,10 +25,14 @@
jorton 8e7e0a
 
jorton 8e7e0a
 #include "apu_config.h"
jorton 8e7e0a
 
jorton 8e7e0a
-#ifdef APR_HAVE_OLD_EXPAT
jorton 8e7e0a
-#include "xmlparse.h"
jorton 8e7e0a
+#if defined(HAVE_XMLPARSE_XMLPARSE_H)
jorton 8e7e0a
+#include <xmlparse/xmlparse.h>
jorton 8e7e0a
+#elif defined(HAVE_XMLTOK_XMLPARSE_H)
jorton 8e7e0a
+#include <xmltok/xmlparse.h>
jorton 8e7e0a
+#elif defined(HAVE_XML_XMLPARSE_H)
jorton 8e7e0a
+#include <xml/xmlparse.h>
jorton 8e7e0a
 #else
jorton 8e7e0a
-#include "expat.h"
jorton 8e7e0a
+#include <expat.h>
jorton 8e7e0a
 #endif
jorton 8e7e0a
 
jorton 8e7e0a
 #define DEBUG_CR "\r\n"
jorton 8e7e0a
--- apr-util-1.2.8/build/apu-conf.m4.autoexpat
jorton 8e7e0a
+++ apr-util-1.2.8/build/apu-conf.m4
jorton 8e7e0a
@@ -46,92 +46,75 @@
jorton 8e7e0a
   AC_SUBST(APR_BUILD_DIR)
jorton 8e7e0a
 ])
jorton 8e7e0a
 
jorton 8e7e0a
-
jorton 8e7e0a
-dnl
jorton 8e7e0a
-dnl APU_TEST_EXPAT(directory): test if Expat is located in the specified dir
jorton 8e7e0a
 dnl
jorton 8e7e0a
-dnl if present: sets expat_include_dir, expat_libs, possibly expat_old
jorton 8e7e0a
+dnl APU_TRY_EXPAT_LINK(
jorton 8e7e0a
+dnl      test-message, cache-var-name, hdrs, libs,
jorton 8e7e0a
+dnl      [actions-on-success], [actions-on-failure])
jorton 8e7e0a
+dnl         
jorton 8e7e0a
+dnl Tests linking against expat with libraries 'libs' and includes
jorton 8e7e0a
+dnl 'hdrs', passing message + cache-var-name to AC_CACHE_CHECK.
jorton 8e7e0a
+dnl On success, sets $expat_libs to libs, sets $apu_have_expat to 1, 
jorton 8e7e0a
+dnl and runs actions-on-success; on failure runs actions-on-failure.
jorton 8e7e0a
+dnl
jorton 8e7e0a
+AC_DEFUN([APU_TRY_EXPAT_LINK], [
jorton 8e7e0a
+AC_CACHE_CHECK([$1], [$2], [
jorton 8e7e0a
+  apu_expat_LIBS=$LIBS
jorton 8e7e0a
+  LIBS="$LIBS $4"
jorton 8e7e0a
+  AC_TRY_LINK([#include <stdlib.h>
jorton 8e7e0a
+#include <$3>], [XML_ParserCreate(NULL);],
jorton 8e7e0a
+    [$2=yes], [$2=no])
jorton 8e7e0a
+  LIBS=$apu_expat_LIBS
jorton 8e7e0a
+])
jorton 8e7e0a
+
jorton 8e7e0a
+if test $[$2] = yes; then
jorton 8e7e0a
+   AC_DEFINE([HAVE_]translit([$3], [a-z./], [A-Z__]), 1,
jorton 8e7e0a
+             [Define if $3 is available])
jorton 8e7e0a
+   apu_expat_libs="$4"
jorton 8e7e0a
+   apu_has_expat=1
jorton 8e7e0a
+   $5
jorton 8e7e0a
+else
jorton 8e7e0a
+   apu_has_expat=0
jorton 8e7e0a
+   $6
jorton 8e7e0a
+fi
jorton 8e7e0a
+])
jorton 8e7e0a
+
jorton 8e7e0a
 dnl
jorton 8e7e0a
-AC_DEFUN([APU_TEST_EXPAT], [
jorton 8e7e0a
-  AC_MSG_CHECKING(for Expat in ifelse($2,,$1,$2))
jorton 8e7e0a
+dnl APU_SYSTEM_EXPAT: tests for a system expat installation
jorton 8e7e0a
+dnl If present, sets $apu_has_expat to 1 and adjusts LDFLAGS/CPPFLAGS
jorton 8e7e0a
+dnl appropriately.  This is mostly for compatibility with existing
jorton 8e7e0a
+dnl expat releases; all but the first APU_TRY_EXPAT_LINK call could
jorton 8e7e0a
+dnl be dropped later.
jorton 8e7e0a
+dnl
jorton 8e7e0a
+AC_DEFUN([APU_SYSTEM_EXPAT], [
jorton 8e7e0a
+ 
jorton 8e7e0a
+  APU_TRY_EXPAT_LINK([Expat 1.95.x], apu_cv_expat_system, 
jorton 8e7e0a
+    [expat.h], [-lexpat])
jorton 8e7e0a
+
jorton 8e7e0a
+  if test $apu_has_expat = 0; then
jorton 8e7e0a
+    APU_TRY_EXPAT_LINK([old Debian-packaged expat], apu_cv_expat_debian,
jorton 8e7e0a
+       [xmltok/xmlparse.h], [-lxmlparse -lxmltok])
jorton 8e7e0a
+  fi
jorton 8e7e0a
 
jorton 8e7e0a
-  expat_libtool=""
jorton 8e7e0a
+  if test $apu_has_expat = 0; then
jorton 8e7e0a
+    APU_TRY_EXPAT_LINK([old FreeBSD-packaged expat], apu_cv_expat_freebsd,
jorton 8e7e0a
+       [xml/xmlparse.h], [-lexpat])
jorton 8e7e0a
+  fi
jorton 8e7e0a
 
jorton 8e7e0a
-  if test -r "$1/lib/expat.h.in"; then
jorton 8e7e0a
-    dnl Expat 1.95.* distribution
jorton 8e7e0a
-    expat_include_dir="$1/lib"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_libtool="$1/lib/libexpat.la"
jorton 8e7e0a
-  elif test -r "$1/include/expat.h" -a \
jorton 8e7e0a
-    -r "$1/lib/libexpat.la"; then
jorton 8e7e0a
-    dnl Expat 1.95.* installation (with libtool)
jorton 8e7e0a
-    expat_include_dir="$1/include"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_libtool="$1/lib/libexpat.la"
jorton 8e7e0a
-  elif test -r "$1/include/expat.h" -a \
jorton 8e7e0a
-    -r "$1/lib64/libexpat.la"; then
jorton 8e7e0a
-    dnl Expat 1.95.* installation on certain 64-bit platforms (with libtool)
jorton 8e7e0a
-    expat_include_dir="$1/include"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib64"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_libtool="$1/lib64/libexpat.la"
jorton 8e7e0a
-  elif test -r "$1/include/expat.h" -a \
jorton 8e7e0a
-    -r "$1/lib/libexpat.a"; then
jorton 8e7e0a
-    dnl Expat 1.95.* installation (without libtool)
jorton 8e7e0a
-    dnl FreeBSD textproc/expat2
jorton 8e7e0a
-    expat_include_dir="$1/include"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-  elif test -r "$1/xmlparse.h"; then
jorton 8e7e0a
-    dnl maybe an expat-lite. use this dir for both includes and libs
jorton 8e7e0a
-    expat_include_dir="$1"
jorton 8e7e0a
-    expat_ldflags="-L$1"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_libtool="$1/libexpat.la"
jorton 8e7e0a
-    expat_old=yes
jorton 8e7e0a
-  elif test -r "$1/include/xmlparse.h" -a \
jorton 8e7e0a
-       -r "$1/lib/libexpat.a"; then
jorton 8e7e0a
-    dnl previously installed expat
jorton 8e7e0a
-    expat_include_dir="$1/include"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_old=yes
jorton 8e7e0a
-  elif test -r "$1/include/xml/xmlparse.h" -a \
jorton 8e7e0a
-       -r "$1/lib/xml/libexpat.a"; then
jorton 8e7e0a
-    dnl previously installed expat
jorton 8e7e0a
-    expat_include_dir="$1/include/xml"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_old=yes
jorton 8e7e0a
-  elif test -r "$1/include/xmltok/xmlparse.h"; then
jorton 8e7e0a
-    dnl Debian distribution
jorton 8e7e0a
-    expat_include_dir="$1/include/xmltok"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib"
jorton 8e7e0a
-    expat_libs="-lxmlparse -lxmltok"
jorton 8e7e0a
-    expat_old=yes
jorton 8e7e0a
-  elif test -r "$1/include/xml/xmlparse.h" -a \
jorton 8e7e0a
-       -r "$1/lib/libexpat.a"; then
jorton 8e7e0a
-    dnl FreeBSD textproc/expat package
jorton 8e7e0a
-    expat_include_dir="$1/include/xml"
jorton 8e7e0a
-    expat_ldflags="-L$1/lib"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_old=yes
jorton 8e7e0a
-  elif test -r "$1/xmlparse/xmlparse.h"; then
jorton 8e7e0a
-    dnl Expat 1.0 or 1.1 source directory
jorton 8e7e0a
-    expat_include_dir="$1/xmlparse"
jorton 8e7e0a
-    expat_ldflags="-L$1"
jorton 8e7e0a
-    expat_libs="-lexpat"
jorton 8e7e0a
-    expat_old=yes
jorton 8e7e0a
+  if test $apu_has_expat = 0; then
jorton 8e7e0a
+    APU_TRY_EXPAT_LINK([Expat 1.0/1.1], apu_cv_expat_1011,
jorton 8e7e0a
+       [xmlparse/xmlparse.h], [-lexpat])
jorton 8e7e0a
   fi
jorton 8e7e0a
-  dnl ### test for installed Expat 1.95.* distros
jorton 8e7e0a
 
jorton 8e7e0a
-  if test -n "$expat_include_dir"; then
jorton 8e7e0a
-    dnl ### more info about what we found there? version? using .la?
jorton 8e7e0a
-    AC_MSG_RESULT(yes)
jorton 8e7e0a
-  else
jorton 8e7e0a
-    AC_MSG_RESULT(no)
jorton 8e7e0a
+  if test $apu_has_expat = 0; then
jorton 8e7e0a
+    APR_ADDTO(LDFLAGS, [-L/usr/local/lib])
jorton 8e7e0a
+    APR_ADDTO(CPPFLAGS, [-I/usr/local/include])
jorton 8e7e0a
+ 
jorton 8e7e0a
+    APU_TRY_EXPAT_LINK([Expat 1.95.x in /usr/local], 
jorton 8e7e0a
+       apu_cv_expat_usrlocal, [expat.h], [-lexpat],
jorton 8e7e0a
+       [APR_ADDTO(APRUTIL_INCLUDES, [-I/usr/local/include])],[
jorton 8e7e0a
+       APR_REMOVEFROM(LDFLAGS, [-L/usr/local/lib])
jorton 8e7e0a
+       APR_REMOVEFROM(CPPFLAGS, [-I/usr/local/include])
jorton 8e7e0a
+      ])
jorton 8e7e0a
   fi
jorton 8e7e0a
 ])
jorton 8e7e0a
 
jorton 8e7e0a
@@ -141,90 +124,51 @@
jorton 8e7e0a
 dnl
jorton 8e7e0a
 AC_DEFUN([APU_FIND_EXPAT], [
jorton 8e7e0a
 
jorton 8e7e0a
+apu_has_expat=0
jorton 8e7e0a
+
jorton 8e7e0a
+# Default: will use either external or bundled expat.
jorton 8e7e0a
+apu_try_external_expat=1
jorton 8e7e0a
+apu_try_builtin_expat=1
jorton 8e7e0a
+
jorton 8e7e0a
 AC_ARG_WITH([expat],
jorton 8e7e0a
-[  --with-expat=DIR        specify Expat location or 'builtin'], [
jorton 8e7e0a
+[  --with-expat=DIR        specify Expat location, or 'builtin'], [
jorton 8e7e0a
   if test "$withval" = "yes"; then
jorton 8e7e0a
     AC_MSG_ERROR([a directory must be specified for --with-expat])
jorton 8e7e0a
   elif test "$withval" = "no"; then
jorton 8e7e0a
     AC_MSG_ERROR([Expat cannot be disabled (at this time)])
jorton 8e7e0a
   elif test "$withval" = "builtin"; then
jorton 8e7e0a
-    abs_expatdir="`cd $srcdir/xml/expat && pwd`"
jorton 8e7e0a
-    if test -d $abs_expatdir/. -a ! -d xml/expat/.; then
jorton 8e7e0a
-      $mkdir_p xml/expat
jorton 8e7e0a
-    fi
jorton 8e7e0a
-    APU_TEST_EXPAT($abs_expatdir, xml/expat)
jorton 8e7e0a
+    apu_try_external_expat=0
jorton 8e7e0a
   else
jorton 8e7e0a
-    abs_expatdir="`cd $withval && pwd`"
jorton 8e7e0a
-    APU_TEST_EXPAT($abs_expatdir, $withval)
jorton 8e7e0a
-    if test -z "$expat_include_dir"; then
jorton 8e7e0a
-      AC_MSG_ERROR([Expat was not found (or recognized) in \"$withval\"])
jorton 8e7e0a
+    # Add given path to standard search paths if appropriate:
jorton 8e7e0a
+    if test "$withval" != "/usr"; then
jorton 8e7e0a
+      APR_ADDTO(LDFLAGS, [-L$withval/lib])
jorton 8e7e0a
+      APR_ADDTO(CPPFLAGS, [-I$withval/include])
jorton 8e7e0a
+      APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
jorton 8e7e0a
     fi
jorton 8e7e0a
+    # ...and refuse to fall back on the builtin expat.
jorton 8e7e0a
+    apu_try_builtin_expat=0
jorton 8e7e0a
   fi
jorton 8e7e0a
 ])
jorton 8e7e0a
 
jorton 8e7e0a
-if test -z "$expat_include_dir"; then
jorton 8e7e0a
-  for d in /usr /usr/local xml/expat-cvs xml/expat $srcdir/xml/expat ; do
jorton 8e7e0a
-    APU_TEST_EXPAT($d)
jorton 8e7e0a
-    if test -n "$expat_include_dir"; then
jorton 8e7e0a
-      dnl For /usr installs of expat, we can't specify -L/usr/lib
jorton 8e7e0a
-      if test "$d" = "/usr"; then
jorton 8e7e0a
-        expat_ldflags=""
jorton 8e7e0a
-      fi
jorton 8e7e0a
-      break
jorton 8e7e0a
-    fi
jorton 8e7e0a
-  done
jorton 8e7e0a
-fi
jorton 8e7e0a
-if test -z "$expat_include_dir"; then
jorton 8e7e0a
-  AC_MSG_ERROR([could not locate Expat. use --with-expat])
jorton 8e7e0a
-fi
jorton 8e7e0a
-
jorton 8e7e0a
-dnl If this expat doesn't use libtool natively, we'll mimic it for our
jorton 8e7e0a
-dnl dependency library generation.
jorton 8e7e0a
-if test -z "$expat_libtool"; then
jorton 8e7e0a
-  expat_libtool="$expat_ldflags $expat_libs" 
jorton 8e7e0a
+if test $apu_try_external_expat = 1; then
jorton 8e7e0a
+  APU_SYSTEM_EXPAT
jorton 8e7e0a
 fi
jorton 8e7e0a
 
jorton 8e7e0a
-if test -n "$expat_old"; then
jorton 8e7e0a
-  AC_DEFINE(APR_HAVE_OLD_EXPAT, 1, [define if Expat 1.0 or 1.1 was found])
jorton 8e7e0a
-fi
jorton 8e7e0a
-
jorton 8e7e0a
-dnl special-case the bundled distribution (use absolute dirs)
jorton 8e7e0a
-if test "$expat_include_dir" = "xml/expat/lib" -o "$expat_include_dir" = "xml/expat-cvs/lib"; then
jorton 8e7e0a
-  bundled_subdir="`echo $expat_include_dir | sed -e 's%/lib%%'`"
jorton 8e7e0a
-  APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir])
jorton 8e7e0a
-  expat_include_dir=$top_builddir/$bundled_subdir/lib
jorton 8e7e0a
-  expat_ldflags="-L$top_builddir/$bundled_subdir/lib"
jorton 8e7e0a
-  expat_libs="-lexpat"
jorton 8e7e0a
-  expat_libtool=$top_builddir/$bundled_subdir/lib/libexpat.la
jorton 8e7e0a
-  APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`"
jorton 8e7e0a
-  APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool])
jorton 8e7e0a
-else
jorton 8e7e0a
-if test "$expat_include_dir" = "$abs_srcdir/xml/expat/include" -o "$expat_include_dir" = "$abs_srcdir/xml/expat/lib"; then
jorton 8e7e0a
+if test "${apu_has_expat}${apu_try_builtin_expat}" = "01"; then
jorton 8e7e0a
   dnl This is a bit of a hack.  This only works because we know that
jorton 8e7e0a
   dnl we are working with the bundled version of the software.
jorton 8e7e0a
   bundled_subdir="xml/expat"
jorton 8e7e0a
   APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir])
jorton 8e7e0a
-  expat_include_dir=$top_builddir/$bundled_subdir/lib
jorton 8e7e0a
-  expat_ldflags="-L$top_builddir/$bundled_subdir/lib"
jorton 8e7e0a
-  expat_libs="-lexpat"
jorton 8e7e0a
-  expat_libtool=$top_builddir/$bundled_subdir/lib/libexpat.la
jorton 8e7e0a
-  APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`"
jorton 8e7e0a
-  APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool])
jorton 8e7e0a
-else
jorton 8e7e0a
-  APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libs])
jorton 8e7e0a
-fi
jorton 8e7e0a
+  APR_ADDTO(APRUTIL_INCLUDES, [-I$top_builddir/$bundled_subdir/lib])
jorton 8e7e0a
+  APR_ADDTO(LDFLAGS, [-L$top_builddir/$bundled_subdir/lib])
jorton 8e7e0a
+  apu_expat_libs="$top_builddir/$bundled_subdir/lib/libexpat.la"
jorton 8e7e0a
 fi
jorton 8e7e0a
+
jorton 8e7e0a
+APR_ADDTO(APRUTIL_EXPORT_LIBS, [$apu_expat_libs])
jorton 8e7e0a
+APR_ADDTO(APRUTIL_LIBS, [$apu_expat_libs])
jorton 8e7e0a
+
jorton 8e7e0a
 APR_XML_DIR=$bundled_subdir
jorton 8e7e0a
-APR_XML_EXPAT_OLD=$expat_old
jorton 8e7e0a
-AC_SUBST(APR_XML_SUBDIRS)
jorton 8e7e0a
 AC_SUBST(APR_XML_DIR)
jorton 8e7e0a
-AC_SUBST(APR_XML_EXPAT_OLD)
jorton 8e7e0a
-
jorton 8e7e0a
-if test "$expat_include_dir" != "/usr/include"; then
jorton 8e7e0a
-  APR_ADDTO(APRUTIL_INCLUDES, [-I$expat_include_dir])
jorton 8e7e0a
-fi
jorton 8e7e0a
-APR_ADDTO(APRUTIL_LDFLAGS, [$expat_ldflags])
jorton 8e7e0a
-APR_ADDTO(APRUTIL_LIBS, [$expat_libtool])
jorton 8e7e0a
 ])
jorton 8e7e0a
 
jorton 8e7e0a