-# libxml.m4 serial 6 (gettext-0.18.2)
-dnl Copyright (C) 2006, 2008, 2011, 2013, 2016 Free Software Foundation, Inc.
+# libxml.m4 serial 7
+dnl Copyright (C) 2006, 2008, 2011, 2013, 2016, 2019 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
+dnl gl_LIBXML
+dnl gives the user the option to decide whether to use the included or
+dnl an external libxml.
+dnl gl_LIBXML(FORCE-INCLUDED)
+dnl forces the use of the included or an external libxml.
AC_DEFUN([gl_LIBXML],
[
AC_REQUIRE([AM_ICONV_LINK])
- AC_MSG_CHECKING([whether included libxml is requested])
- AC_ARG_WITH([included-libxml],
- [ --with-included-libxml use the libxml2 included here],
- [gl_cv_libxml_force_included=$withval],
- [gl_cv_libxml_force_included=no])
- AC_MSG_RESULT([$gl_cv_libxml_force_included])
+ ifelse([$1], , [
+ AC_MSG_CHECKING([whether included libxml is requested])
+ AC_ARG_WITH([included-libxml],
+ [ --with-included-libxml use the libxml2 included here],
+ [gl_cv_libxml_force_included=$withval],
+ [gl_cv_libxml_force_included=no])
+ AC_MSG_RESULT([$gl_cv_libxml_force_included])
+ ], [gl_cv_libxml_force_included=$1])
gl_cv_libxml_use_included="$gl_cv_libxml_force_included"
LIBXML=
LTLIBXML=
INCXML=
- if test "$gl_cv_libxml_use_included" != yes; then
- dnl Figure out whether we can use a preinstalled libxml2, or have to use
- dnl the included one.
- AC_CACHE_VAL([gl_cv_libxml], [
- gl_cv_libxml=no
- gl_cv_LIBXML=
- gl_cv_LTLIBXML=
- gl_cv_INCXML=
- gl_save_LIBS="$LIBS"
- LIBS="$LIBS $LIBICONV"
- dnl Search for libxml2 and define LIBXML2, LTLIBXML2 and INCXML2
- dnl accordingly.
- dnl Don't use xml2-config nor pkg-config, since it doesn't work when
- dnl cross-compiling or when the C compiler in use is different from the
- dnl one that built the library.
- dnl Use a test program that tries to invoke xmlFree. On Cygwin 1.7.x,
- dnl libxml2 is built in such a way that uses of xmlFree work fine with
- dnl -Wl,--enable-auto-import but lead to a link error with
- dnl -Wl,--disable-auto-import.
- AC_LIB_LINKFLAGS_BODY([xml2])
- LIBS="$gl_save_LIBS $LIBXML2 $LIBICONV"
- AC_TRY_LINK([#include <libxml/xmlversion.h>
- #include <libxml/xmlmemory.h>
- #include <libxml/xpath.h>
- ],
- [xmlCheckVersion (0);
- xmlFree ((void *) 0);
- xmlXPathSetContextNode ((void *)0, (void *)0);
- ],
- [gl_cv_libxml=yes
- gl_cv_LIBXML="$LIBXML2 $LIBICONV"
- gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV"
- ])
- if test "$gl_cv_libxml" != yes; then
- gl_save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $INCXML2"
+ ifelse([$1], [yes], , [
+ if test "$gl_cv_libxml_use_included" != yes; then
+ dnl Figure out whether we can use a preinstalled libxml2, or have to use
+ dnl the included one.
+ AC_CACHE_VAL([gl_cv_libxml], [
+ gl_cv_libxml=no
+ gl_cv_LIBXML=
+ gl_cv_LTLIBXML=
+ gl_cv_INCXML=
+ gl_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBICONV"
+ dnl Search for libxml2 and define LIBXML2, LTLIBXML2 and INCXML2
+ dnl accordingly.
+ dnl Don't use xml2-config nor pkg-config, since it doesn't work when
+ dnl cross-compiling or when the C compiler in use is different from the
+ dnl one that built the library.
+ dnl Use a test program that tries to invoke xmlFree. On Cygwin 1.7.x,
+ dnl libxml2 is built in such a way that uses of xmlFree work fine with
+ dnl -Wl,--enable-auto-import but lead to a link error with
+ dnl -Wl,--disable-auto-import.
+ AC_LIB_LINKFLAGS_BODY([xml2])
+ LIBS="$gl_save_LIBS $LIBXML2 $LIBICONV"
AC_TRY_LINK([#include <libxml/xmlversion.h>
#include <libxml/xmlmemory.h>
#include <libxml/xpath.h>
[gl_cv_libxml=yes
gl_cv_LIBXML="$LIBXML2 $LIBICONV"
gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV"
- gl_cv_INCXML="$INCXML2"
])
if test "$gl_cv_libxml" != yes; then
- dnl Often the include files are installed in /usr/include/libxml2.
- dnl In libxml2-2.5, <libxml/xmlversion.h> is self-contained.
- dnl In libxml2-2.6, it includes <libxml/xmlexports.h> which is
- dnl self-contained.
- libxml2_include_dir=
- AC_TRY_CPP([#include <libxml2/libxml/xmlexports.h>],
- [gl_ABSOLUTE_HEADER([libxml2/libxml/xmlexports.h])
- libxml2_include_dir=`echo "$gl_cv_absolute_libxml2_libxml_xmlexports_h" | sed -e 's,.libxml.xmlexports\.h$,,'`
+ gl_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $INCXML2"
+ AC_TRY_LINK([#include <libxml/xmlversion.h>
+ #include <libxml/xmlmemory.h>
+ #include <libxml/xpath.h>
+ ],
+ [xmlCheckVersion (0);
+ xmlFree ((void *) 0);
+ xmlXPathSetContextNode ((void *)0, (void *)0);
+ ],
+ [gl_cv_libxml=yes
+ gl_cv_LIBXML="$LIBXML2 $LIBICONV"
+ gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV"
+ gl_cv_INCXML="$INCXML2"
])
- if test -z "$libxml2_include_dir"; then
- AC_TRY_CPP([#include <libxml2/libxml/xmlversion.h>],
- [gl_ABSOLUTE_HEADER([libxml2/libxml/xmlversion.h])
- libxml2_include_dir=`echo "$gl_cv_absolute_libxml2_libxml_xmlversion_h" | sed -e 's,.libxml.xmlversion\.h$,,'`
- ])
- fi
- if test -n "$libxml2_include_dir" && test -d "$libxml2_include_dir"; then
- CPPFLAGS="$gl_save_CPPFLAGS -I$libxml2_include_dir"
- AC_TRY_LINK([#include <libxml/xmlversion.h>
- #include <libxml/xmlmemory.h>
- #include <libxml/xpath.h>
- ],
- [xmlCheckVersion (0);
- xmlFree ((void *) 0);
- xmlXPathSetContextNode ((void *)0, (void *)0);
- ],
- [gl_cv_libxml=yes
- gl_cv_LIBXML="$LIBXML2 $LIBICONV"
- gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV"
- gl_cv_INCXML="-I$libxml2_include_dir"
+ if test "$gl_cv_libxml" != yes; then
+ dnl Often the include files are installed in /usr/include/libxml2.
+ dnl In libxml2-2.5, <libxml/xmlversion.h> is self-contained.
+ dnl In libxml2-2.6, it includes <libxml/xmlexports.h> which is
+ dnl self-contained.
+ libxml2_include_dir=
+ AC_TRY_CPP([#include <libxml2/libxml/xmlexports.h>],
+ [gl_ABSOLUTE_HEADER([libxml2/libxml/xmlexports.h])
+ libxml2_include_dir=`echo "$gl_cv_absolute_libxml2_libxml_xmlexports_h" | sed -e 's,.libxml.xmlexports\.h$,,'`
])
+ if test -z "$libxml2_include_dir"; then
+ AC_TRY_CPP([#include <libxml2/libxml/xmlversion.h>],
+ [gl_ABSOLUTE_HEADER([libxml2/libxml/xmlversion.h])
+ libxml2_include_dir=`echo "$gl_cv_absolute_libxml2_libxml_xmlversion_h" | sed -e 's,.libxml.xmlversion\.h$,,'`
+ ])
+ fi
+ if test -n "$libxml2_include_dir" && test -d "$libxml2_include_dir"; then
+ CPPFLAGS="$gl_save_CPPFLAGS -I$libxml2_include_dir"
+ AC_TRY_LINK([#include <libxml/xmlversion.h>
+ #include <libxml/xmlmemory.h>
+ #include <libxml/xpath.h>
+ ],
+ [xmlCheckVersion (0);
+ xmlFree ((void *) 0);
+ xmlXPathSetContextNode ((void *)0, (void *)0);
+ ],
+ [gl_cv_libxml=yes
+ gl_cv_LIBXML="$LIBXML2 $LIBICONV"
+ gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV"
+ gl_cv_INCXML="-I$libxml2_include_dir"
+ ])
+ fi
fi
+ CPPFLAGS="$gl_save_CPPFLAGS"
fi
- CPPFLAGS="$gl_save_CPPFLAGS"
+ LIBS="$gl_save_LIBS"
+ ])
+ AC_MSG_CHECKING([for libxml])
+ AC_MSG_RESULT([$gl_cv_libxml])
+ if test $gl_cv_libxml = yes; then
+ LIBXML="$gl_cv_LIBXML"
+ LTLIBXML="$gl_cv_LTLIBXML"
+ INCXML="$gl_cv_INCXML"
+ else
+ gl_cv_libxml_use_included=yes
fi
- LIBS="$gl_save_LIBS"
- ])
- AC_MSG_CHECKING([for libxml])
- AC_MSG_RESULT([$gl_cv_libxml])
- if test $gl_cv_libxml = yes; then
- LIBXML="$gl_cv_LIBXML"
- LTLIBXML="$gl_cv_LTLIBXML"
- INCXML="$gl_cv_INCXML"
- else
- gl_cv_libxml_use_included=yes
fi
- fi
+ ])
AC_SUBST([LIBXML])
AC_SUBST([LTLIBXML])
AC_SUBST([INCXML])