Blame build/find_xml.m4

Packit 284210
dnl Check for LIBXML2 Libraries
Packit 284210
dnl CHECK_LIBXML2(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
Packit 284210
dnl Sets:
Packit 284210
dnl  LIBXML2_CFLAGS
Packit 284210
dnl  LIBXML2_LIBS
Packit 284210
Packit 284210
LIBXML2_CONFIG=""
Packit 284210
LIBXML2_VERSION=""
Packit 284210
LIBXML2_CFLAGS=""
Packit 284210
LIBXML2_CPPFLAGS=""
Packit 284210
LIBXML2_LDADD=""
Packit 284210
LIBXML2_LDFLAGS=""
Packit 284210
Packit 284210
AC_DEFUN([CHECK_LIBXML2],
Packit 284210
[dnl
Packit 284210
Packit 284210
AC_ARG_WITH(
Packit 284210
    libxml,
Packit 284210
    [AC_HELP_STRING([--with-libxml=PATH],[Path to libxml2 prefix or config script])],
Packit 284210
    [test_paths="${with_libxml}"],
Packit 284210
    [test_paths="/usr/local/libxml2 /usr/local/xml2 /usr/local/xml /usr/local /opt/libxml2 /opt/libxml /opt/xml2 /opt/xml /opt /usr"])
Packit 284210
Packit 284210
AC_MSG_CHECKING([for libxml2 config script])
Packit 284210
Packit 284210
for x in ${test_paths}; do
Packit 284210
    dnl # Determine if the script was specified and use it directly
Packit 284210
    if test ! -d "$x" -a -e "$x"; then
Packit 284210
        LIBXML2_CONFIG=$x
Packit 284210
        libxml2_path="no"
Packit 284210
        break
Packit 284210
    fi
Packit 284210
Packit 284210
    dnl # Try known config script names/locations
Packit 284210
    for LIBXML2_CONFIG in xml2-config xml-2-config xml-config; do
Packit 284210
        if test -e "${x}/bin/${LIBXML2_CONFIG}"; then
Packit 284210
            libxml2_path="${x}/bin"
Packit 284210
            break
Packit 284210
        elif test -e "${x}/${LIBXML2_CONFIG}"; then
Packit 284210
            libxml2_path="${x}"
Packit 284210
            break
Packit 284210
        else
Packit 284210
            libxml2_path=""
Packit 284210
        fi
Packit 284210
    done
Packit 284210
    if test -n "$libxml2_path"; then
Packit 284210
        break
Packit 284210
    fi
Packit 284210
done
Packit 284210
Packit 284210
if test -n "${libxml2_path}"; then
Packit 284210
    if test "${libxml2_path}" != "no"; then
Packit 284210
        LIBXML2_CONFIG="${libxml2_path}/${LIBXML2_CONFIG}"
Packit 284210
    fi
Packit 284210
    AC_MSG_RESULT([${LIBXML2_CONFIG}])
Packit 284210
    LIBXML2_VERSION=`${LIBXML2_CONFIG} --version | sed 's/^[[^0-9]][[^[:space:]]][[^[:space:]]]*[[[:space:]]]*//'`
Packit 284210
    if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(xml VERSION: $LIBXML2_VERSION); fi
Packit 284210
    LIBXML2_CFLAGS="`${LIBXML2_CONFIG} --cflags`"
Packit 284210
    if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(xml CFLAGS: $LIBXML2_CFLAGS); fi
Packit 284210
    LIBXML2_LDADD="`${LIBXML2_CONFIG} --libs`"
Packit 284210
    if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(xml LDADD: $LIBXML2_LDADD); fi
Packit 284210
Packit 284210
    AC_MSG_CHECKING([if libxml2 is at least v2.6.29])
Packit 284210
    libxml2_min_ver=`echo 2.6.29 | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
Packit 284210
    libxml2_ver=`echo ${LIBXML2_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
Packit 284210
    if test "$libxml2_ver" -ge "$libxml2_min_ver"; then
Packit 284210
        AC_MSG_RESULT([yes, $LIBXML2_VERSION])
Packit 284210
    else
Packit 284210
        AC_MSG_RESULT([no, $LIBXML2_VERSION])
Packit 284210
        AC_MSG_ERROR([NOTE: libxml2 library must be at least 2.6.29])
Packit 284210
    fi
Packit 284210
Packit 284210
else
Packit 284210
    AC_MSG_RESULT([no])
Packit 284210
fi
Packit 284210
Packit 284210
AC_SUBST(LIBXML2_CONFIG)
Packit 284210
AC_SUBST(LIBXML2_VERSION)
Packit 284210
AC_SUBST(LIBXML2_CFLAGS)
Packit 284210
AC_SUBST(LIBXML2_CPPFLAGS)
Packit 284210
AC_SUBST(LIBXML2_LDADD)
Packit 284210
AC_SUBST(LIBXML2_LDFLAGS)
Packit 284210
Packit 284210
if test -z "${LIBXML2_VERSION}"; then
Packit 284210
    AC_MSG_NOTICE([*** xml library not found.])
Packit 284210
    ifelse([$2], , AC_MSG_ERROR([libxml2 is required]), $2)
Packit 284210
else
Packit 284210
    AC_MSG_NOTICE([using libxml2 v${LIBXML2_VERSION}])
Packit 284210
    ifelse([$1], , , $1) 
Packit 284210
fi
Packit 284210
])