[libvirt] [libvirt-php] Fixed checking for libxml2 and prerequisites
Michal Novotny
minovotn at redhat.com
Tue Feb 22 07:10:33 UTC 2011
On 02/22/2011 03:15 AM, Lyre wrote:
> Repalced AM_PATH_XML2 with with the script borrowed
> from libvirt, which was borrowed from xmlsec.
>
> modified: configure.ac
> modified: src/Makefile.am
> ---
> configure.ac | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
> src/Makefile.am | 4 ++--
> 2 files changed, 50 insertions(+), 4 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index ac31bd0..b87c7f9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -10,12 +10,58 @@ AC_PROG_CC
> AC_LANG([C])
> AC_PROG_INSTALL
> AC_PROG_SED
> +AC_PROG_AWK
> AC_CHECK_TOOL([STRIP], [strip])
> AC_CHECK_TOOL([ECHO], [echo])
> AC_CHECK_TOOL([RM], [rm])
>
> -dnl Check for libxml2
> -AM_PATH_XML2([2.0.0])
> +dnl Need to test if pkg-config exists
> +PKG_PROG_PKG_CONFIG
> +
> +dnl ==========================================================================
> +dnl required minimum version of libxml2
> +dnl replace "2.0.0" with an appropriate one
> +dnl ==========================================================================
> +LIBXML_REQUIRED="2.0.0"
> +
> +dnl ==========================================================================
> +dnl find libxml2 library, borrowed from xmlsec
> +dnl ==========================================================================
> +LIBXML_CONFIG="xml2-config"
> +LIBXML_CFLAGS=""
> +LIBXML_LIBS=""
> +LIBXML_FOUND="no"
> +
> +AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@], [libxml2 location]))
> +if test "x$with_libxml" = "xno" ; then
> + AC_MSG_CHECKING(for libxml2 libraries>= $LIBXML_REQUIRED)
> + AC_MSG_ERROR([libxml2>= $LIBXML_REQUIRED is required for libvirt])
> +elif test "x$with_libxml" = "x"&& test "x$PKG_CONFIG" != "x" ; then
> + PKG_CHECK_MODULES(LIBXML, libxml-2.0>= $LIBXML_REQUIRED, [LIBXML_FOUND=yes], [LIBXML_FOUND=no])
> +fi
> +if test "$LIBXML_FOUND" = "no" ; then
> + if test "x$with_libxml" != "x" ; then
> + LIBXML_CONFIG=$with_libxml/bin/$LIBXML_CONFIG
> + fi
> + AC_MSG_CHECKING(libxml2 $LIBXML_CONFIG>= $LIBXML_REQUIRED )
> + if ! $LIBXML_CONFIG --version> /dev/null 2>&1 ; then
> + AC_MSG_ERROR([Could not find libxml2 anywhere (see config.log for details).])
> + fi
> + vers=`$LIBXML_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
> + minvers=`echo $LIBXML_REQUIRED | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
> + if test "$vers" -ge "$minvers" ; then
> + LIBXML_LIBS="`$LIBXML_CONFIG --libs`"
> + LIBXML_CFLAGS="`$LIBXML_CONFIG --cflags`"
> + LIBXML_FOUND="yes"
> + AC_MSG_RESULT(yes)
> + else
> + AC_MSG_ERROR(
> + [You need at least libxml2 $LIBXML_REQUIRED for this version of libvirt])
> + fi
> +fi
> +
> +AC_SUBST([LIBXML_CFLAGS])
> +AC_SUBST([LIBXML_LIBS])
>
> dnl Specific XML catalog file for validation of generated html
> AC_ARG_WITH([xml-catalog-file],
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 9e89f9f..1826b09 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -7,8 +7,8 @@ EXTRA_DIST = libvirt.c php_libvirt.h
> all-am: build clean-temp
>
> build:
> - $(CC) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt.c $(XML_CPPFLAGS)
> - $(CC) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt $(XML_LIBS)
> + $(CC) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt.c $(LIBXML_CFLAGS)
> + $(CC) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt $(LIBXML_LIBS)
> $(ECHO) "Extension compiled as $(PACKAGE).so"
>
> install-exec-local:
That's much better Lyre. It's compiling and working fine now. I've
pushed it to the repository.
Thanks,
Michal
--
Michal Novotny<minovotn at redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat
More information about the libvir-list
mailing list