]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vbox: Let configure detect/set the XPCOMC directory
authorMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 29 Jun 2010 18:01:45 +0000 (20:01 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 3 Jul 2010 10:40:14 +0000 (12:40 +0200)
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
src/vbox/vbox_XPCOMCGlue.c

index 691ef690b0fb05085c541645f5f1a28920696f2c..cab01c2e66501c9d4437ae08614a6be4c233b9a6 100644 (file)
@@ -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
index 0987c1b30928d750289342429349fff3171efb75..e8b0bd1fedf94f9cd910e3034572658018df8990 100644 (file)
@@ -29,9 +29,8 @@
 /*******************************************************************************
 *   Header Files                                                               *
 *******************************************************************************/
-#ifdef LIBVIRT_VERSION
-# include <config.h>
-#endif /* LIBVIRT_VERSION */
+
+#include <config.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -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)
-        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.