Change detection of xen so that it's actually automatic rather than forced.

This ensures that ./configure will work fine if xen development packages
are not around, rather than fail. When passing ./configure --with-xen, the
lack of xen development packages become fatal.
This commit is contained in:
Diego Elio Pettenò 2010-01-17 15:48:46 +01:00 committed by Matthias Bolte
parent 4d434da34c
commit 3c58896eb7

View File

@ -205,7 +205,7 @@ fi
dnl Allow to build without Xen, QEMU/KVM, test or remote driver
AC_ARG_WITH([xen],
AC_HELP_STRING([--with-xen], [add XEN support @<:@default=yes@:>@]),[],[with_xen=yes])
AC_HELP_STRING([--with-xen], [add XEN support @<:@default=check@:>@]),[],[with_xen=check])
AC_ARG_WITH([xen-inotify],
AC_HELP_STRING([--with-xen-inotify], [add XEN inotify support @<:@default=check@:>@]),[],[with_xen_inotify=check])
AC_ARG_WITH([qemu],
@ -334,6 +334,8 @@ if test "$with_libvirtd" = "yes" ; then
fi
AM_CONDITIONAL([WITH_LIBVIRTD], [test "$with_libvirtd" = "yes"])
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
XEN_LIBS=""
XEN_CFLAGS=""
dnl search for the Xen store library
@ -343,52 +345,58 @@ if test "$with_xen" != "no" ; then
XEN_LIBS="-L$with_xen/lib64 -L$with_xen/lib"
fi
fail=0
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $XEN_CFLAGS"
LIBS="$LIBS $XEN_LIBS"
AC_CHECK_LIB([xenstore], [xs_read], [
with_xen=yes
XEN_LIBS="$XEN_LIBS -lxenstore"
],[
if test "$with_xen" = "check" ; then
with_xen=no
else
with_xen=no
if test "$with_xen" = "yes"; then
fail=1
fi
with_xen=no
])
test $fail = 1 &&
AC_MSG_ERROR([You must install the Xen development package to compile Xen driver with -lxenstore])
AC_CHECK_HEADERS([xen/xen.h xen/version.h xen/dom0_ops.h],,[
AC_MSG_ERROR([Cannot find standard Xen headers. Is xen-devel installed?])
],
[#include <stdio.h>
#include <stdint.h>
])
dnl Search for the location of <xen/{linux,sys}/privcmd.h>.
AC_CHECK_HEADERS([xen/sys/privcmd.h],,[
AC_CHECK_HEADERS([xen/linux/privcmd.h],,[
AC_MSG_ERROR([Cannot find header file <xen/linux/privcmd.h> or <xen/sys/privcmd.h>. Is xen-devel installed?])
],
[#include <stdio.h>
#include <stdint.h>
#include <xen/xen.h>
])
],
[#include <stdio.h>
#include <stdint.h>
#include <xen/xen.h>
])
LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
fi
if test "$with_xen" != "no" ; then
AC_CHECK_HEADERS([xen/xen.h xen/version.h xen/dom0_ops.h],,[
if test "$with_xen" = "yes"; then
fail=1
fi
with_xen=no
],
[#include <stdio.h>
#include <stdint.h>
])
fi
if test "$with_xen" != "no" ; then
dnl Search for the location of <xen/{linux,sys}/privcmd.h>.
found=
AC_CHECK_HEADERS([xen/sys/privcmd.h xen/linux/privcmd.h], [found=yes; break;], [],
[#include <stdio.h>
#include <stdint.h>
#include <xen/xen.h>
])
if test "x$found" != "xyes"; then
if test "$with_xen" = "yes"; then
fail=1
fi
with_xen=no
fi
fi
LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
if test $fail = 1; then
AC_MSG_ERROR([You must install the Xen development package to compile Xen driver with -lxenstore])
fi
if test "$with_xen" = "yes"; then
AC_DEFINE_UNQUOTED([WITH_XEN], 1, [whether Xen driver is enabled])
fi
AM_CONDITIONAL([WITH_XEN], [test "$with_xen" = "yes"])
AC_SUBST([XEN_CFLAGS])
AC_SUBST([XEN_LIBS])