From df90ca7661b0a789bd790ccf8258a4527c13eb8d Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Tue, 29 Jun 2010 20:01:45 +0200 Subject: [PATCH] vbox: Let configure detect/set the XPCOMC directory This allows the user to give an explicit path to configure ./configure --with-vbox=/path/to/virtualbox instead of having the VirtualBox driver probe a set of possible paths at runtime. If no explicit path is specified then configure probes the set of "known" paths. https://bugzilla.redhat.com/show_bug.cgi?id=609185 --- configure.ac | 60 +++++++++++++++++++++++++++++++++++++- src/vbox/vbox_XPCOMCGlue.c | 27 ++++------------- 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index 691ef690b0..cab01c2e66 100644 --- a/configure.ac +++ b/configure.ac @@ -232,7 +232,9 @@ AC_ARG_WITH([phyp], AC_ARG_WITH([xenapi], AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=check@:>@]),[],[with_xenapi=check]) AC_ARG_WITH([vbox], - AC_HELP_STRING([--with-vbox], [add VirtualBox support @<:@default=yes@:>@]),[],[with_vbox=yes]) + AC_HELP_STRING([--with-vbox=@<:@PFX@:>@], + [VirtualBox XPCOMC location @<:@default=check@:>@]),[], + [with_vbox=check]) AC_ARG_WITH([lxc], AC_HELP_STRING([--with-lxc], [add Linux Container support @<:@default=check@:>@]),[],[with_lxc=check]) AC_ARG_WITH([one], @@ -315,6 +317,62 @@ if test "$with_openvz" = "yes"; then fi AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"]) + +dnl +dnl check for VirtualBox XPCOMC location +dnl + +vbox_xpcomc_dir= + +if test "x$with_vbox" = "xyes" || test "x$with_vbox" = "xcheck"; then + AC_MSG_CHECKING([for VirtualBox XPCOMC location]) + + for vbox in \ + /usr/lib/virtualbox/VBoxXPCOMC.so \ + /usr/lib/VirtualBox/VBoxXPCOMC.so \ + /opt/virtualbox/VBoxXPCOMC.so \ + /opt/VirtualBox/VBoxXPCOMC.so \ + /opt/virtualbox/i386/VBoxXPCOMC.so \ + /opt/VirtualBox/i386/VBoxXPCOMC.so \ + /opt/virtualbox/amd64/VBoxXPCOMC.so \ + /opt/VirtualBox/amd64/VBoxXPCOMC.so \ + /usr/local/lib/virtualbox/VBoxXPCOMC.so \ + /usr/local/lib/VirtualBox/VBoxXPCOMC.so \ + /Application/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib \ + ; do + if test -f "$vbox"; then + vbox_xpcomc_dir=`AS_DIRNAME(["$vbox"])` + break + fi + done + + if test -n "$vbox_xpcomc_dir"; then + AC_MSG_RESULT([$vbox_xpcomc_dir]) + with_vbox=yes + else + if test "x$with_vbox" = "xcheck"; then + AC_MSG_RESULT([not found, disabling VirtualBox driver]) + with_vbox=no + else + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([VirtualBox XPCOMC is required for the VirtualBox driver]) + fi + fi +else + if test "x$with_vbox" != "xno"; then + if test -f ${with_vbox}/VBoxXPCOMC.so || \ + test -f ${with_vbox}/VBoxXPCOMC.dylib; then + vbox_xpcomc_dir=$with_vbox + with_vbox=yes + else + AC_MSG_ERROR([$with_vbox does not contain VirtualBox XPCOMC]) + fi + fi +fi + +AC_DEFINE_UNQUOTED([VBOX_XPCOMC_DIR], ["$vbox_xpcomc_dir"], + [Location of directory containing VirtualBox XPCOMC library]) + if test "x$with_vbox" = "xyes"; then AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([Unable to find dlopen()])]) case $ac_cv_search_dlopen in diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c index 0987c1b309..e8b0bd1fed 100644 --- a/src/vbox/vbox_XPCOMCGlue.c +++ b/src/vbox/vbox_XPCOMCGlue.c @@ -29,9 +29,8 @@ /******************************************************************************* * Header Files * *******************************************************************************/ -#ifdef LIBVIRT_VERSION -# include -#endif /* LIBVIRT_VERSION */ + +#include #include #include @@ -192,28 +191,12 @@ int VBoxCGlueInit(void) return tryLoadOne(pszHome, 0); /* - * Try the known standard locations. + * Try the configured location. */ g_szVBoxErrMsg[0] = '\0'; -#if defined(__gnu__linux__) || defined(__linux__) - if (tryLoadOne("/opt/VirtualBox", 1) == 0) + + if (tryLoadOne(VBOX_XPCOMC_DIR, 1) == 0) return 0; - if (tryLoadOne("/usr/lib/virtualbox", 1) == 0) - return 0; -#elif defined(__sun__) - if (tryLoadOne("/opt/VirtualBox/amd64", 1) == 0) - return 0; - if (tryLoadOne("/opt/VirtualBox/i386", 1) == 0) - return 0; -#elif defined(__APPLE__) - if (tryLoadOne("/Application/VirtualBox.app/Contents/MacOS", 1) == 0) - return 0; -#elif defined(__FreeBSD__) - if (tryLoadOne("/usr/local/lib/virtualbox", 1) == 0) - return 0; -#else -# error "port me" -#endif /* * Finally try the dynamic linker search path.