[PATCH] vbox: Let configure detect/set the XPCOMC directory

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

 



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               |   73 +++++++++++++++++++++++++++++++++++++++++++-
 src/Makefile.am            |    1 +
 src/vbox/vbox_XPCOMCGlue.c |   22 ++-----------
 3 files changed, 76 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index 691ef69..a1ba2f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -232,7 +232,7 @@ 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 +315,77 @@ 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])
+
+    if test -f /usr/lib/virtualbox/VBoxXPCOMC.so; then
+        vbox_xpcomc_dir=/usr/lib/virtualbox
+    else
+        if test -f /usr/lib/VirtualBox/VBoxXPCOMC.so; then
+            vbox_xpcomc_dir=/usr/lib/VirtualBox
+        else
+            if test -f /opt/virtualbox/VBoxXPCOMC.so; then
+                vbox_xpcomc_dir=/opt/virtualbox
+            else
+                if test -f /opt/virtualbox/VBoxXPCOMC.so; then
+                    vbox_xpcomc_dir=/opt/virtualbox
+                else
+                    if test -f /opt/VirtualBox/i386/VBoxXPCOMC.so; then
+                        vbox_xpcomc_dir=/opt/VirtualBox/i386
+                    else
+                        if test -f /opt/VirtualBox/amd64/VBoxXPCOMC.so; then
+                            vbox_xpcomc_dir=/opt/VirtualBox/amd64
+                        else
+                            if test -f /usr/local/lib/virtualbox/VBoxXPCOMC.so; then
+                                vbox_xpcomc_dir=/usr/local/lib/virtualbox
+                            else
+                                if test -f /usr/lib/local/VirtualBox/VBoxXPCOMC.so; then
+                                    vbox_xpcomc_dir=/usr/lib/local/VirtualBox
+                                else
+                                    if test -f /Application/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib; then
+                                        vbox_xpcomc_dir=/Application/VirtualBox.app/Contents/MacOS
+                                    fi
+                                fi
+                            fi
+                        fi
+                    fi
+                fi
+            fi
+        fi
+    fi
+
+    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_SUBST([vbox_xpcomc_dir])
+
 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/Makefile.am b/src/Makefile.am
index ece18a6..d3c7087 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,7 @@ INCLUDES =							\
 		-DPKGDATADIR=\""$(pkgdatadir)"\"		\
 		-DLOCAL_STATE_DIR=\""$(localstatedir)"\"	\
 		-DGETTEXT_PACKAGE=\"$(PACKAGE)\"		\
+		-DVBOX_XPCOMC_DIR=\"$(vbox_xpcomc_dir)\"		\
 		$(WARN_CFLAGS)					\
 		$(LOCK_CHECKING_CFLAGS)			\
 		-DIN_LIBVIRT				\
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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]