Hello

I've only recently found out that even OSE has an option for remote
access to headless VirtualBox machines through VNC. Unfortunately, the
current configure script used for building the OSE does not mention
this capability anywhere in the --help output, nor does it support
trivial enabling through a --enable-feautre switch.

I've attached a small patch for the configure script allowing user to
pass the --enable-vnc configuration option to it. The patch will check
for the existence of libvncserver by compiling a small program which
also checks that the libvncserver is of version of at least 0.9.7.

The version-checking code is a bit crude since the libvncserver doesn't
provide version information as a numeric constant in its headers. I've
put down several lines of code for converting the constant char array
into an unsigned integer. If you have any suggestions on improving this
in any way, please let me know.

The patch is licensed under the MIT license.

-- 
Branko Majic
Jabber: [email protected]
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: [email protected]
Молим вас да додатке шаљете искључиво у слободним форматима.
--- configure.orig	2010-11-20 20:35:43.399739771 +0100
+++ configure	2010-11-20 22:04:15.523490599 +0100
@@ -87,6 +87,7 @@
 WITH_OPENGL=1
 WITH_HARDENING=1
 WITH_VDE=0
+WITH_VNC=0
 BUILD_LIBXML2=
 BUILD_LIBXSLT=
 BUILD_LIBCURL=
@@ -122,6 +123,8 @@
 LIBZ="-lz"
 INCPNG=""
 LIBPNG="-lpng"
+INCVNCSERVER=""
+LIBVNCSERVER="-lvncserver"
 CXX_FLAGS=""
 if [ "$OS" = "freebsd" ]; then
   INCCURL="-I/usr/local/include"
@@ -949,6 +952,47 @@
 }
 
 #
+# Check for libvncserver, needed for VNC in OSE
+#
+check_vncserver()
+{
+    test_header libvncserver
+    cat > $ODIR.tmp_src.cc <<EOF
+#include <cstdio>
+#include <rfb/rfbconfig.h>
+
+extern "C" int main()
+{
+  const char* v=LIBVNCSERVER_VERSION;
+  unsigned int major = 0, minor = 0, micro = 0;
+
+  for (; *v !='.' && *v != '\0'; v++) major = major*10 + *v-'0';
+  if (*v == '.') v++;
+  for (; *v !='.' && *v != '\0'; v++) minor = minor*10 + *v-'0';
+  if (*v == '.') v++;
+  for (; *v !='.' && *v != '\0'; v++) micro = micro*10 + *v-'0';
+
+  printf("found version %s", LIBVNCSERVER_PACKAGE_VERSION);
+  if (major*10000 + minor*100 + micro >= 907)
+  {
+  printf(", OK.\n");
+  return 0;
+  }
+  else
+  {
+    printf(", expected version 0.9.7 or higher\n");
+    return 1;
+  }
+}
+EOF
+  if test_compile "$LIBVNCSERVER $INCVNCSERVER" libvncserver libvncserver; then
+    if test_execute; then
+      cnf_append "VBOX_WITH_VNC" "1"
+    fi
+  fi
+}
+
+#
 # Check for libcurl, needed by S3
 #
 check_curl()
@@ -2063,6 +2107,7 @@
 [ $WITH_KMODS   -eq 1 ] && echo "  --disable-kmods          don't build Linux kernel modules (host and guest)"
 [ $WITH_OPENGL  -eq 1 ] && echo "  --disable-opengl         disable OpenGL support (2D & 3D)"
 [ $WITH_GSOAP   -eq 0 ] && echo "  --enable-webservice      enable the webservice stuff"
+[ $OSE          -eq 1 ] && echo "  --enable-vnc             enable the VNC server"
 [ "$OS" = "linux" -o "$OS" = "freebsd" ] && echo "  --enable-vde             enable VDE networking"
 cat << EOF
   --disable-hardening      don't be strict about /dev/vboxdrv access
@@ -2224,6 +2269,9 @@
     --enable-webservice)
       [ $WITH_GSOAP -eq 0 ] && WITH_GSOAP=1
       ;;
+    --enable-vnc)
+      WITH_VNC=1
+      ;;
     --disable-hardening)
       WITH_HARDENING=0
       ;;
@@ -2484,6 +2532,15 @@
   fi
 fi
 
+# VNC server support
+if [ $OSE -ge 1 ]; then
+  if [ $WITH_VNC = 1 ]; then
+    check_vncserver
+  else
+    cnf_append "VBOX_WITH_VNC" ""
+  fi
+fi
+
 # success!
 echo
 echo "Successfully generated '$CNF' and '$ENV'."

Attachment: signature.asc
Description: PGP signature

_______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev

Reply via email to