[libvirt-php] Fixed checking for libxml2 and prerequisites

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:
-- 
1.7.1


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]