[virt-tools-list] [PATCH 42/47] Use pkg-config for checking for libxml
Daniel P. Berrange
berrange at redhat.com
Wed Aug 25 19:37:37 UTC 2010
Rather than creating huge amounts of m4 logic, just use pkg-config
to check for libxml2 library. Make libxml2 compulsory
* configure.ac: Simplify libxml2 check
---
configure.ac | 47 +--------------------------------------------
osinfo/osinfo_dataread.c | 10 ---------
2 files changed, 2 insertions(+), 55 deletions(-)
diff --git a/configure.ac b/configure.ac
index a088ae7..e6969c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,10 +15,8 @@ AM_MAINTAINER_MODE([enable])
# Use the silent-rules feature when possible.
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
-LIBXML_REQUIRED=2.6.0
-
-#PKG_CHECK_MODULES([GLIB], [glib-2.0], [GLIB_FOUND=yes], [GLIB_FOUND=no])
-PKG_CHECK_MODULES([GOBJECT], [gobject-2.0], [GOBJECT_FOUND=yes], [GOBJECT_FOUND=no])
+PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])
+PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.6.0])
LIBOSINFO_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
LIBOSINFO_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
@@ -59,47 +57,6 @@ AC_SUBST([NO_UNDEFINED_FLAGS])
AC_SUBST([VERSION_SCRIPT_FLAGS])
AM_CONDITIONAL([USE_VERSION_DEFS], [test "$USE_VERSION_DEFS" = "1"])
-
-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" -a "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 (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])
-
AC_CONFIG_FILES([
Makefile
osinfo/Makefile
diff --git a/osinfo/osinfo_dataread.c b/osinfo/osinfo_dataread.c
index a6dbc32..a6575f1 100644
--- a/osinfo/osinfo_dataread.c
+++ b/osinfo/osinfo_dataread.c
@@ -8,8 +8,6 @@
#include <osinfo/osinfo.h>
-#ifdef LIBXML_READER_ENABLED
-
#define TEXT_NODE 3
#define ELEMENT_NODE 1
#define END_NODE 15
@@ -746,11 +744,3 @@ cleanup:
xmlCleanupParser();
g_free(backingDir);
}
-
-#else
-void osinfo_dataread(OsinfoDb *db, GError **err)
-{
- g_set_error_literal(err, g_quark_from_static_string("libosinfo"), 0,
- "xml loading not available");
-}
-#endif
--
1.7.2.1
More information about the virt-tools-list
mailing list