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

[libvirt] [PATCH v2] 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
---

v2:
 - address Eric's comments
   - wrap AC_HELP_STRING at 80 columns
   - replace the if/else with a for loop, much nicer, indeed :)
   - use AC_DEFINE_UNQUOTED instead of AC_SUBST to define VBOX_XPCOMC_DIR

 configure.ac               |   60 +++++++++++++++++++++++++++++++++++++++++++-
 src/vbox/vbox_XPCOMCGlue.c |   22 ++--------------
 2 files changed, 62 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index 691ef69..cab01c2 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 0987c1b..fcae0cb 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -192,28 +192,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)
-        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)
+
+    if (tryLoadOne(VBOX_XPCOMC_DIR, 1) == 0)
         return 0;
-#else
-# error "port me"
-#endif
 
     /*
      * Finally try the dynamic linker search path.
-- 
1.7.0.4


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