3 #   AX_LIB_XML2([MINIMUM-VERSION])
 
   7 #   This macro provides tests of availability of xml2 'libxml2' library
 
   8 #   of particular version or newer.
 
  10 #   AX_LIB_LIBXML2 macro takes only one argument which is optional. If
 
  11 #   there is no required version passed, then macro does not run version
 
  14 #   The --with-libxml2 option takes one of three possible values:
 
  16 #   no - do not check for xml2 library
 
  18 #   yes - do check for xml2 library in standard locations (xml2-config
 
  19 #   should be in the PATH)
 
  21 #   path - complete path to xml2-config utility, use this option if xml2-config
 
  22 #   can't be found in the PATH
 
  26 #     AC_SUBST(XML2_CFLAGS)
 
  27 #     AC_SUBST(XML2_LDFLAGS)
 
  28 #     AC_SUBST(XML2_VERSION)
 
  36 #   Copyright (c) 2009 Hartmut Holzgraefe <hartmut@php.net>
 
  38 #   Copying and distribution of this file, with or without modification, are
 
  39 #   permitted in any medium without royalty provided the copyright notice
 
  40 #   and this notice are preserved.
 
  42 AC_DEFUN([AX_LIB_XML2],
 
  44     AC_ARG_WITH([libxml2],
 
  45         AC_HELP_STRING([--with-libxml2=@<:@ARG@:>@],
 
  46             [use libxml2 library @<:@default=yes@:>@, optionally specify path to xml2-config]
 
  49         if test "$withval" = "no"; then
 
  51         elif test "$withval" = "yes"; then
 
  55             XML2_CONFIG="$withval"
 
  66     dnl Check xml2 libraries (libxml2)
 
  69     if test "$want_libxml2" = "yes"; then
 
  71         if test -z "$XML2_CONFIG" -o test; then
 
  72             AC_PATH_PROG([XML2_CONFIG], [xml2-config], [])
 
  75         if test ! -x "$XML2_CONFIG"; then
 
  76             AC_MSG_ERROR([$XML2_CONFIG does not exist or it is not an exectuable file])
 
  81         if test "$XML2_CONFIG" != "no"; then
 
  82             AC_MSG_CHECKING([for xml2 libraries])
 
  84             XML2_CFLAGS="`$XML2_CONFIG --cflags`"
 
  85             XML2_LDFLAGS="`$XML2_CONFIG --libs`"
 
  87             XML2_VERSION=`$XML2_CONFIG --version`
 
  89             AC_DEFINE([HAVE_XML2], [1],
 
  90                 [Define to 1 if xml2 libraries are available])
 
 101     dnl Check if required version of xml2 is available
 
 105     libxml2_version_req=ifelse([$1], [], [], [$1])
 
 108     if test "$found_libxml2" = "yes" -a -n "$libxml2_version_req"; then
 
 110         AC_MSG_CHECKING([if libxml2 version is >= $libxml2_version_req])
 
 112         dnl Decompose required version string of libxml2
 
 113         dnl and calculate its number representation
 
 114         libxml2_version_req_major=`expr $libxml2_version_req : '\([[0-9]]*\)'`
 
 115         libxml2_version_req_minor=`expr $libxml2_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
 
 116         libxml2_version_req_micro=`expr $libxml2_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
 
 117         if test "x$libxml2_version_req_micro" = "x"; then
 
 118             libxml2_version_req_micro="0"
 
 121         libxml2_version_req_number=`expr $libxml2_version_req_major \* 1000000 \
 
 122                                    \+ $libxml2_version_req_minor \* 1000 \
 
 123                                    \+ $libxml2_version_req_micro`
 
 125         dnl Decompose version string of installed PostgreSQL
 
 126         dnl and calculate its number representation
 
 127         libxml2_version_major=`expr $XML2_VERSION : '\([[0-9]]*\)'`
 
 128         libxml2_version_minor=`expr $XML2_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
 
 129         libxml2_version_micro=`expr $XML2_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
 
 130         if test "x$libxml2_version_micro" = "x"; then
 
 131             libxml2_version_micro="0"
 
 134         libxml2_version_number=`expr $libxml2_version_major \* 1000000 \
 
 135                                    \+ $libxml2_version_minor \* 1000 \
 
 136                                    \+ $libxml2_version_micro`
 
 138         libxml2_version_check=`expr $libxml2_version_number \>\= $libxml2_version_req_number`
 
 139         if test "$libxml2_version_check" = "1"; then
 
 146     AC_SUBST([XML2_VERSION])
 
 147     AC_SUBST([XML2_CFLAGS])
 
 148     AC_SUBST([XML2_LDFLAGS])