| 1 |
# Copyright (C) 1998-2005, 2007 Joe Orton <[email protected]> -*- autoconf -*- |
| 2 |
# |
| 3 |
# This file is free software; you may copy and/or distribute it with |
| 4 |
# or without modifications, as long as this notice is preserved. |
| 5 |
# This software is distributed in the hope that it will be useful, but |
| 6 |
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even |
| 7 |
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 8 |
# PURPOSE. |
| 9 |
|
| 10 |
# The above license applies to THIS FILE ONLY, the neon library code |
| 11 |
# itself may be copied and distributed under the terms of the GNU |
| 12 |
# LGPL, see COPYING.LIB for more details |
| 13 |
|
| 14 |
# This file is part of the neon HTTP/WebDAV client library. |
| 15 |
# See http://www.webdav.org/neon/ for the latest version. |
| 16 |
# Please send any feedback to <[email protected]> |
| 17 |
|
| 18 |
# Check for XML parser, supporting libxml 2.x and expat 1.95.x, |
| 19 |
# or a bundled copy of expat. |
| 20 |
# * Bundled expat if a directory name argument is passed |
| 21 |
# -> expat dir must contain minimal expat sources, i.e. |
| 22 |
# xmltok, xmlparse sub-directories. See sitecopy/cadaver for |
| 23 |
# examples of how to do this. |
| 24 |
# |
| 25 |
# Usage: |
| 26 |
# NEON_XML_PARSER() |
| 27 |
# or |
| 28 |
# NEON_XML_PARSER([expat-srcdir], [expat-builddir]) |
| 29 |
|
| 30 |
dnl Find expat: run $1 if found, else $2 |
| 31 |
AC_DEFUN([NE_XML_EXPAT], [ |
| 32 |
AC_CHECK_HEADER(expat.h, |
| 33 |
[AC_CHECK_LIB(expat, XML_SetXmlDeclHandler, [ |
| 34 |
AC_DEFINE(HAVE_EXPAT, 1, [Define if you have expat]) |
| 35 |
neon_xml_parser_message="expat" |
| 36 |
NEON_LIBS="$NEON_LIBS -lexpat" |
| 37 |
neon_xml_parser=expat |
| 38 |
AC_CHECK_TYPE(XML_Size, |
| 39 |
[NEON_FORMAT(XML_Size, [#include <expat.h>])], |
| 40 |
[AC_DEFINE_UNQUOTED([NE_FMT_XML_SIZE], ["d"])], |
| 41 |
[#include <expat.h>]) |
| 42 |
], [$1])], [$1]) |
| 43 |
]) |
| 44 |
|
| 45 |
dnl Find libxml2: run $1 if found, else $2 |
| 46 |
AC_DEFUN([NE_XML_LIBXML2], [ |
| 47 |
AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config) |
| 48 |
if test -n "$XML2_CONFIG"; then |
| 49 |
neon_xml_parser_message="libxml `$XML2_CONFIG --version`" |
| 50 |
AC_DEFINE(HAVE_LIBXML, 1, [Define if you have libxml]) |
| 51 |
# xml2-config in some versions erroneously includes -I/include |
| 52 |
# in the --cflags output. |
| 53 |
CPPFLAGS="$CPPFLAGS `$XML2_CONFIG --cflags | sed 's| -I/include||g'`" |
| 54 |
NEON_LIBS="$NEON_LIBS `$XML2_CONFIG --libs | sed 's|-L/usr/lib ||g'`" |
| 55 |
AC_CHECK_HEADERS(libxml/xmlversion.h libxml/parser.h,,[ |
| 56 |
AC_MSG_ERROR([could not find parser.h, libxml installation problem?])]) |
| 57 |
neon_xml_parser=libxml2 |
| 58 |
else |
| 59 |
$1 |
| 60 |
fi |
| 61 |
]) |
| 62 |
|
| 63 |
dnl Configure for a bundled expat build. |
| 64 |
AC_DEFUN([NE_XML_BUNDLED_EXPAT], [ |
| 65 |
|
| 66 |
AC_REQUIRE([AC_C_BIGENDIAN]) |
| 67 |
# Define XML_BYTE_ORDER for expat sources. |
| 68 |
if test $ac_cv_c_bigendian = "yes"; then |
| 69 |
ne_xml_border=21 |
| 70 |
else |
| 71 |
ne_xml_border=12 |
| 72 |
fi |
| 73 |
|
| 74 |
# mini-expat doesn't pick up config.h |
| 75 |
CPPFLAGS="$CPPFLAGS -DXML_BYTE_ORDER=$ne_xml_border -DXML_DTD -I$1/xmlparse -I$1/xmltok" |
| 76 |
|
| 77 |
AC_DEFINE_UNQUOTED([NE_FMT_XML_SIZE], ["d"]) |
| 78 |
|
| 79 |
# Use the bundled expat sources |
| 80 |
AC_LIBOBJ($2/xmltok/xmltok) |
| 81 |
AC_LIBOBJ($2/xmltok/xmlrole) |
| 82 |
AC_LIBOBJ($2/xmlparse/xmlparse) |
| 83 |
AC_LIBOBJ($2/xmlparse/hashtable) |
| 84 |
|
| 85 |
AC_DEFINE(HAVE_EXPAT) |
| 86 |
|
| 87 |
AC_DEFINE(HAVE_XMLPARSE_H, 1, [Define if using expat which includes xmlparse.h]) |
| 88 |
|
| 89 |
]) |
| 90 |
|
| 91 |
AC_DEFUN([NEON_XML_PARSER], [ |
| 92 |
|
| 93 |
dnl Switches to force choice of library |
| 94 |
AC_ARG_WITH([libxml2], |
| 95 |
AS_HELP_STRING([--with-libxml2], [force use of libxml 2.x])) |
| 96 |
AC_ARG_WITH([expat], |
| 97 |
AS_HELP_STRING([--with-expat], [force use of expat])) |
| 98 |
|
| 99 |
dnl Flag to force choice of included expat, if available. |
| 100 |
ifelse($#, 2, [ |
| 101 |
AC_ARG_WITH([included-expat], |
| 102 |
AS_HELP_STRING([--with-included-expat], [use bundled expat sources]),, |
| 103 |
with_included_expat=no)], |
| 104 |
with_included_expat=no) |
| 105 |
|
| 106 |
if test "$NEON_NEED_XML_PARSER" = "yes"; then |
| 107 |
# Find an XML parser |
| 108 |
neon_xml_parser=none |
| 109 |
|
| 110 |
# Forced choice of expat: |
| 111 |
case $with_expat in |
| 112 |
yes) NE_XML_EXPAT([AC_MSG_ERROR([expat library not found, cannot proceed])]) ;; |
| 113 |
no) ;; |
| 114 |
*/libexpat.la) |
| 115 |
# Special case for Subversion |
| 116 |
ne_expdir=`echo $with_expat | sed 's:/libexpat.la$::'` |
| 117 |
AC_DEFINE(HAVE_EXPAT) |
| 118 |
AC_DEFINE_UNQUOTED([NE_FMT_XML_SIZE], ["d"]) |
| 119 |
CPPFLAGS="$CPPFLAGS -I$ne_expdir" |
| 120 |
if test "x${NEON_TARGET}" = "xlibneon.la"; then |
| 121 |
NEON_LTLIBS=$with_expat |
| 122 |
else |
| 123 |
# no dependency on libexpat => crippled libneon, so do partial install |
| 124 |
ALLOW_INSTALL=lib |
| 125 |
fi |
| 126 |
neon_xml_parser=expat |
| 127 |
neon_xml_parser_message="expat in $ne_expdir" |
| 128 |
;; |
| 129 |
/*) AC_MSG_ERROR([--with-expat does not take a directory argument]) ;; |
| 130 |
esac |
| 131 |
|
| 132 |
# If expat wasn't specifically enabled and libxml was: |
| 133 |
if test "${neon_xml_parser}-${with_libxml2}-${with_included_expat}" = "none-yes-no"; then |
| 134 |
NE_XML_LIBXML2( |
| 135 |
[AC_MSG_ERROR([libxml2.x library not found, cannot proceed])]) |
| 136 |
fi |
| 137 |
|
| 138 |
# Otherwise, by default search for expat then libxml2: |
| 139 |
if test "${neon_xml_parser}-${with_included_expat}" = "none-no"; then |
| 140 |
NE_XML_EXPAT([NE_XML_LIBXML2([:])]) |
| 141 |
fi |
| 142 |
|
| 143 |
# If an XML parser still has not been found, fail or use the bundled expat |
| 144 |
if test "$neon_xml_parser" = "none"; then |
| 145 |
m4_if($1, [], |
| 146 |
[AC_MSG_ERROR([no XML parser was found: expat or libxml 2.x required])], |
| 147 |
[# Configure the bundled copy of expat |
| 148 |
NE_XML_BUNDLED_EXPAT($@) |
| 149 |
neon_xml_parser_message="bundled expat in $1"]) |
| 150 |
fi |
| 151 |
|
| 152 |
AC_MSG_NOTICE([XML parser used: $neon_xml_parser_message]) |
| 153 |
fi |
| 154 |
|
| 155 |
]) |