Index: /trunk/src/VBox/HostDrivers/freebsd/Makefile
===================================================================
--- /trunk/src/VBox/HostDrivers/freebsd/Makefile	(revision 24408)
+++ /trunk/src/VBox/HostDrivers/freebsd/Makefile	(revision 24408)
@@ -0,0 +1,80 @@
+#
+# Makefile for the VirtualBox FreeBSD Host Drivers.
+#
+
+#
+#
+# Copyright (C) 2008-2009 Sun Microsystems, Inc.
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+# Clara, CA 95054 USA or visit http://www.sun.com if you need
+# additional information or have any questions.
+#
+
+KBUILD_VERBOSE =
+
+all:
+	@echo "*** Building 'vboxdrv' module ***"
+	@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv
+	@cp vboxdrv/vboxdrv.ko .
+	@echo
+	@if [ -d vboxnetflt ]; then \
+	    if [ -f vboxdrv/Module.symvers ]; then \
+	        cp vboxdrv/Module.symvers vboxnetflt; \
+	    fi; \
+	    echo "*** Building 'vboxnetflt' module ***"; \
+	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt; \
+	    cp vboxnetflt/vboxnetflt.ko .; \
+	    echo; \
+	fi
+	@if [ -d vboxnetadp ]; then \
+	    if [ -f vboxdrv/Module.symvers ]; then \
+	        cp vboxdrv/Module.symvers vboxnetadp; \
+	    fi; \
+	    echo "*** Building 'vboxnetadp' module ***"; \
+	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp; \
+	    cp vboxnetadp/vboxnetadp.ko .; \
+	    echo; \
+	fi
+
+
+install:
+	@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv install
+	@if [ -d vboxnetflt ]; then \
+	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt install; \
+	fi
+	@if [ -d vboxnetadp ]; then \
+	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp install; \
+	fi
+
+clean:
+	@$(MAKE) -C vboxdrv clean
+	@if [ -d vboxnetflt ]; then \
+	    $(MAKE) -C vboxnetflt clean; \
+	fi
+	@if [ -d vboxnetadp ]; then \
+	    $(MAKE) -C vboxnetadp clean; \
+	fi
+	rm -f vboxdrv.ko vboxnetflt.ko vboxnetadp.ko
+
+load:
+	@for module in vboxnetadp vboxnetflt vboxdrv; do \
+		if kldstat -n "$$module" >/dev/null; then \
+			echo "Removing previously installed $$module module"; \
+			/sbin/kldunload $$module; \
+		fi; \
+	done
+	@for module in vboxdrv vboxnetflt vboxnetadp; do \
+		if test -f $$module.ko; then \
+			echo "Installing $$module module"; \
+			/sbin/kldload ./$$module.ko; \
+		fi; \
+	done
Index: /trunk/src/VBox/HostDrivers/freebsd/export_modules
===================================================================
--- /trunk/src/VBox/HostDrivers/freebsd/export_modules	(revision 24408)
+++ /trunk/src/VBox/HostDrivers/freebsd/export_modules	(revision 24408)
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+#
+# Create a tar archive containing the sources of the vboxdrv kernel module
+#
+# Copyright (C) 2007 Sun Microsystems, Inc.
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+# Clara, CA 95054 USA or visit http://www.sun.com if you need
+# additional information or have any questions.
+#
+
+if [ -z "$1" ]; then
+    echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
+    echo "  Export VirtualBox kernel modules to <filename.tar.gz>"
+    exit 1
+fi
+
+VBOX_WITH_HARDENING=1
+if [ "$2" = "--without-hardening" ]; then
+    VBOX_WITH_HARDENING=
+fi
+
+PATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules"
+PATH_OUT=$PATH_TMP
+FILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
+PATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
+PATH_FREEBSD="$PATH_ROOT/src/VBox/HostDrivers/freebsd"
+PATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
+PATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
+PATH_VBOXNETADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
+
+VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
+VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
+VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
+VBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
+
+. $PATH_VBOXDRV/freebsd/files_vboxdrv
+. $PATH_VBOXNET/freebsd/files_vboxnetflt
+. $PATH_VBOXNETADP/freebsd/files_vboxnetadp
+
+# Temporary path for creating the modules, will be removed later
+mkdir $PATH_TMP || exit 1
+
+# Create auto-generated version file, needed by all modules
+echo "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
+echo "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
+echo "" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
+echo "" >> $PATH_TMP/version-generated.h
+echo "#endif" >> $PATH_TMP/version-generated.h
+
+# vboxdrv (VirtualBox host kernel module)
+mkdir $PATH_TMP/vboxdrv || exit 1
+for f in $FILES_VBOXDRV_NOBIN; do
+    install -d -m 755 "$PATH_TMP/vboxdrv/`dirname $f|cut -d'>' -f2`"
+    install -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
+done
+for f in $FILES_VBOXDRV_BIN; do
+    install -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
+done
+sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_FREEBSD/build_in_tmp > $PATH_TMP/vboxdrv/build_in_tmp
+if [ -n "$VBOX_WITH_HARDENING" ]; then
+    cat                                   $PATH_VBOXDRV/freebsd/Makefile > $PATH_TMP/vboxdrv/Makefile
+else
+    sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/freebsd/Makefile > $PATH_TMP/vboxdrv/Makefile
+fi
+
+# vboxnetflt (VirtualBox netfilter kernel module)
+mkdir $PATH_TMP/vboxnetflt || exit 1
+for f in $VBOX_VBOXNETFLT_SOURCES; do
+    install -d -m 755 "$PATH_TMP/vboxnetflt/`dirname $f|cut -d'>' -f2`"
+    install -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
+done
+sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_FREEBSD/build_in_tmp > $PATH_TMP/vboxnetflt/build_in_tmp
+if [ -n "$VBOX_WITH_HARDENING" ]; then
+    cat                                   $PATH_VBOXNET/freebsd/Makefile > $PATH_TMP/vboxnetflt/Makefile
+else
+    sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/freebsd/Makefile > $PATH_TMP/vboxnetflt/Makefile
+fi
+
+# vboxnetadp (VirtualBox network adapter kernel module)
+mkdir $PATH_TMP/vboxnetadp || exit 1
+for f in $VBOX_VBOXNETADP_SOURCES; do
+    install -d -m 755 "$PATH_TMP/vboxnetadp/`dirname $f|cut -d'>' -f2`"
+    install -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
+done
+sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_FREEBSD/build_in_tmp > $PATH_TMP/vboxnetadp/build_in_tmp
+if [ -n "$VBOX_WITH_HARDENING" ]; then
+    cat                                   $PATH_VBOXNETADP/freebsd/Makefile > $PATH_TMP/vboxnetadp/Makefile
+else
+    sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNETADP/freebsd/Makefile > $PATH_TMP/vboxnetadp/Makefile
+fi
+
+install -m 0644 $PATH_FREEBSD/Makefile $PATH_TMP/Makefile
+
+# Only temporary, omit from archive
+rm $PATH_TMP/version-generated.h
+
+# Create the archive
+tar -czf $FILE_OUT -C $PATH_TMP . || exit 1
+
+# Remove the temporary directory
+rm -r $PATH_TMP
+
