SUMMARY="VirtualBox kernel modules and user-space tools for Haiku guests"
DESCRIPTION="
VirtualBox is a free x86 virtualization solution allowing a wide range \
of x86 operating systems such as Windows, DOS, BSD or Linux to run on a \
Linux system.

This package contains the VirtualBox kernel modules and user-space \
tools for Haiku guests.
"
HOMEPAGE="http://www.virtualbox.org/"
SOURCE_URI="svn+http://www.virtualbox.org/svn/vbox/trunk#53373"
#TODO:check user manual for full list
COPYRIGHT="2003-2014 Oracle Corporation."
#TODO:check user manual for full list
LICENSE="
	GNU GPL v2
	CDDL v1
	"
REVISION="2"
ARCHITECTURES="x86_gcc2 x86 x86_64"

PROVIDES="
	virtualbox_guest_additions$secondaryArchSuffix = $portVersion
	cmd:VBoxControl$secondaryArchSuffix = $portVersion
	cmd:VBoxService$secondaryArchSuffix = $portVersion
	cmd:VBoxTray$secondaryArchSuffix = $portVersion
	"

# TODO: POST_INSTALL_SCRIPTS=""

REQUIRES="
	haiku$secondaryArchSuffix
	openssl$secondaryArchSuffix >= 1.0.0
	lib:libiconv$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libpng$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	"

BUILD_REQUIRES="
	openssl${secondaryArchSuffix}_devel >= 1.0.0
	devel:libiconv$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	# required for kmk_* which are compiled with gcc4
	haiku_x86
	haiku${secondaryArchSuffix}_devel
	cmd:mkisofs
	cmd:grep
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:sed
	cmd:which
	cmd:yasm
	"

PATCHES="virtualbox_guest_additions-$portVersion.patchset"

BUILD()
{
	# use the checked-out kBuild for now
	export PATH="$PATH:$PWD/kBuild/bin/haiku.x86"
	export USER=user
	./configure --build-headless --disable-python --disable-java --nofatal
	source env.sh
	kmk VBOX_ONLY_ADDITIONS=1 VBOX_WITH_ADDITION_DRIVERS=1 BUILD_TYPE=strict all
}

INSTALL()
{
	cd out/haiku.x86/strict/bin/additions
	mkdir -p $addOnsDir/kernel/{generic,drivers/bin,drivers/dev/misc}

	cp vboxguest $addOnsDir/kernel/generic
	cp vboxdev $addOnsDir/kernel/drivers/bin
	ln -fs ../../bin/vboxdev $addOnsDir/kernel/drivers/dev/misc

#	mkdir -p $addOnsDir/kernel/file_systems
#	cp vboxsf $addOnsDir/kernel/file_systems

#	mkdir -p $addOnsDir/{input_server/filters,input_server/devices}
#	cp VBoxMouseFilter $addOnsDir/input_server/filters
#	cp VBoxMouse $addOnsDir/input_server/devices

#	mkdir -p $addOnsDir/{accelerants,kernel/drivers/dev/graphics}
#	cp vboxvideo $addOnsDir/kernel/drivers/bin
#	ln -fs ../../bin/vboxvideo $addOnsDir/kernel/drivers/dev/graphics
#	cp vboxvideo.accelerant $addOnsDir/accelerants
#
	mkdir -p $binDir
	cp VBoxControl $binDir
	cp VBoxService $binDir
	cp VBoxTray $binDir
}

