Dropped the complex macro AM_PATH_XML2.
* configure.ac: repalce the AM_PATH_XML2 with the script borrowed
from libvirt, which was borrowed from xmlsec.
* src/Makefile.am: changed XML_CPPFLAGS to XML_CFLAGS
---
aclocal.m4 | 347 +++++++++++++++++++++++++------------------------------
configure.ac | 43 +++++++-
src/Makefile.am | 2 +-
3 files changed, 199 insertions(+), 193 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index da878b3..45dac6f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -13,200 +13,167 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],,
-[m4_warning([this file was generated for autoconf 2.66.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
+[m4_warning([this file was generated for autoconf 2.65.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
-# Configure paths for LIBXML2
-# Mike Hommey 2004-06-19
-# use CPPFLAGS instead of CFLAGS
-# Toshio Kuratomi 2001-04-21
-# Adapted from:
-# Configure paths for GLIB
-# Owen Taylor 97-11-3
-
-dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
-dnl
-AC_DEFUN([AM_PATH_XML2],[
-AC_ARG_WITH(xml-prefix,
- [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
- xml_config_prefix="$withval", xml_config_prefix="")
-AC_ARG_WITH(xml-exec-prefix,
- [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed
(optional)],
- xml_config_exec_prefix="$withval",
xml_config_exec_prefix="")
-AC_ARG_ENABLE(xmltest,
- [ --disable-xmltest Do not try to compile and run a test LIBXML
program],,
- enable_xmltest=yes)
-
- if test x$xml_config_exec_prefix != x ; then
- xml_config_args="$xml_config_args"
- if test x${XML2_CONFIG+set} != xset ; then
- XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
- fi
- fi
- if test x$xml_config_prefix != x ; then
- xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
- if test x${XML2_CONFIG+set} != xset ; then
- XML2_CONFIG=$xml_config_prefix/bin/xml2-config
- fi
- fi
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+#
+# Copyright © 2004 Scott James Remnant <scott(a)netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
- AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
- min_xml_version=ifelse([$1], ,2.0.0,[$1])
- AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
- no_xml=""
- if test "$XML2_CONFIG" = "no" ; then
- no_xml=yes
- else
- XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
- XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
- xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
- xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
- xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
- if test "x$enable_xmltest" = "xyes" ; then
- ac_save_CPPFLAGS="$CPPFLAGS"
- ac_save_LIBS="$LIBS"
- CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
- LIBS="$XML_LIBS $LIBS"
-dnl
-dnl Now check if the installed libxml is sufficiently new.
-dnl (Also sanity checks the results of xml2-config to some extent)
-dnl
- rm -f conf.xmltest
- AC_TRY_RUN([
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <libxml/xmlversion.h>
-
-int
-main()
-{
- int xml_major_version, xml_minor_version, xml_micro_version;
- int major, minor, micro;
- char *tmp_version;
-
- system("touch conf.xmltest");
-
- /* Capture xml2-config output via autoconf/configure variables */
- /* HP/UX 9 (%@#!) writes to sscanf strings */
- tmp_version = (char *)strdup("$min_xml_version");
- if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3)
{
- printf("%s, bad version string from xml2-config\n",
"$min_xml_version");
- exit(1);
- }
- free(tmp_version);
-
- /* Capture the version information from the header files */
- tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
- if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version,
&xml_minor_version, &xml_micro_version) != 3) {
- printf("%s, bad version string from libxml includes\n",
"LIBXML_DOTTED_VERSION");
- exit(1);
- }
- free(tmp_version);
-
- /* Compare xml2-config output to the libxml headers */
- if ((xml_major_version != $xml_config_major_version) ||
- (xml_minor_version != $xml_config_minor_version) ||
- (xml_micro_version != $xml_config_micro_version))
- {
- printf("*** libxml header files (version %d.%d.%d) do not match\n",
- xml_major_version, xml_minor_version, xml_micro_version);
- printf("*** xml2-config (version %d.%d.%d)\n",
- $xml_config_major_version, $xml_config_minor_version,
$xml_config_micro_version);
- return 1;
- }
-/* Compare the headers to the library to make sure we match */
- /* Less than ideal -- doesn't provide us with return value feedback,
- * only exits if there's a serious mismatch between header and library.
- */
- LIBXML_TEST_VERSION;
-
- /* Test that the library is greater than our minimum version */
- if ((xml_major_version > major) ||
- ((xml_major_version == major) && (xml_minor_version > minor)) ||
- ((xml_major_version == major) && (xml_minor_version == minor) &&
- (xml_micro_version >= micro)))
- {
- return 0;
- }
- else
- {
- printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
- xml_major_version, xml_minor_version, xml_micro_version);
- printf("*** You need a version of libxml newer than %d.%d.%d. The latest
version of\n",
- major, minor, micro);
- printf("*** libxml is always available from
ftp://ftp.xmlsoft.org.\n");
- printf("***\n");
- printf("*** If you have already installed a sufficiently new version, this
error\n");
- printf("*** probably means that the wrong copy of the xml2-config shell
script is\n");
- printf("*** being found. The easiest way to fix this is to remove the old
version\n");
- printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to
point to the\n");
- printf("*** correct copy of xml2-config. (In this case, you will have
to\n");
- printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit
/etc/ld.so.conf\n");
- printf("*** so that the correct libraries are found at run-time))\n");
- }
- return 1;
-}
-],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
- CPPFLAGS="$ac_save_CPPFLAGS"
- LIBS="$ac_save_LIBS"
- fi
- fi
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+#
+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
+# this or PKG_CHECK_MODULES is called, or make sure to call
+# PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_ifval([$2], [$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+ [pkg_failed=yes])
+ else
+ pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
- if test "x$no_xml" = x ; then
- AC_MSG_RESULT(yes (version
$xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
- ifelse([$2], , :, [$2])
- else
- AC_MSG_RESULT(no)
- if test "$XML2_CONFIG" = "no" ; then
- echo "*** The xml2-config script installed by LIBXML could not be
found"
- echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is
in"
- echo "*** your path, or set the XML2_CONFIG environment variable to
the"
- echo "*** full path to xml2-config."
- else
- if test -f conf.xmltest ; then
- :
- else
- echo "*** Could not run libxml test program, checking why..."
- CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
- LIBS="$LIBS $XML_LIBS"
- AC_TRY_LINK([
-#include <libxml/xmlversion.h>
-#include <stdio.h>
-], [ LIBXML_TEST_VERSION; return 0;],
- [ echo "*** The test program compiled, but did not run. This usually
means"
- echo "*** that the run-time linker is not finding LIBXML or finding the
wrong"
- echo "*** version of LIBXML. If it is not finding LIBXML, you'll need
to set your"
- echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to
point"
- echo "*** to the installed location Also, make sure you have run ldconfig
if that"
- echo "*** is required on your system"
- echo "***"
- echo "*** If you have an old version installed, it is best to remove it,
although"
- echo "*** you may also be able to get things to work by modifying
LD_LIBRARY_PATH" ],
- [ echo "*** The test program failed to compile or link. See the file
config.log for the"
- echo "*** exact error that occured. This usually means LIBXML was
incorrectly installed"
- echo "*** or that you have moved LIBXML since it was installed. In the
latter case, you"
- echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
- CPPFLAGS="$ac_save_CPPFLAGS"
- LIBS="$ac_save_LIBS"
- fi
- fi
-
- XML_CPPFLAGS=""
- XML_LIBS=""
- ifelse([$3], , :, [$3])
- fi
- AC_SUBST(XML_CPPFLAGS)
- AC_SUBST(XML_LIBS)
- rm -f conf.xmltest
-])
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2"
2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+ [AC_MSG_RESULT([no])
+ $4])
+elif test $pkg_failed = untried; then
+ ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <
http://pkg-config.freedesktop.org/>.])],
+ [$4])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MODULES
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
#
diff --git a/configure.ac b/configure.ac
index ac31bd0..7c64c86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,8 +14,47 @@ 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 ==========================================================================
+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
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..f7dcffc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,7 @@ 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 -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o $(PACKAGE).o libvirt.c
$(XML_CFLAGS)
$(CC) -Wall -shared $(LIBS) -rdynamic -o $(PACKAGE).so $(PACKAGE).o -ldl -lvirt
$(XML_LIBS)
$(ECHO) "Extension compiled as $(PACKAGE).so"
--
1.7.1