SUMMARY="Tools for using Haiku in a VMware virtual machine"
DESCRIPTION="
VMware add-ons are a set of tools to enhance interaction between Haiku, \
running in a virtual machine, and the host operating system. It is like \
the official VMware tools on Windows or Linux.
It currently provides:
 * Clipboard sharing between Haiku and the host OS
 * Mouse sharing: the mouse can seamlessly enter and quit the VM window.
 * Disk compacting: starts the VMware "shrink" process, which reduces the \
size of "auto-expanding" virtual disks attached to the virtual machine. \
The free space on disks is cleaned up previously, in order to get better \
results.
 * Graphics driver: you can choose your preferred resolution using Screen \
preflet in Haiku."

if [ $effectiveTargetArchitecture = x86_gcc2 ]; then
	DESCRIPTION+="
	 * Shared folders: folders from the host OS can be mounted in Haiku:
   mount -t vmwfs -o 192.168.0.1:/Downloads /Downloads
	"
fi
HOMEPAGE="https://github.com/HaikuArchives/VMwareAddons"
SOURCE_URI="git://github.com/HaikuArchives/VMwareAddons#54a5999ce64b242aa992760adcf4b1ac14e23333"
COPYRIGHT="
	1999 Be Inc.
	2007 Haiku, Inc.
	2009 Vincent Duvert
	"
LICENSE="MIT"
REVISION="2"

ARCHITECTURES="x86_gcc2 x86 !x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	vmware_addons$secondaryArchSuffix = $portVersion
	cmd:vmware_tray$secondaryArchSuffix = $portVersion
	cmd:run_backdoor$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"

if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	REQUIRES+="
		lib:libgcc_s$secondaryArchSuffix
		lib:libsupc++$secondaryArchSuffix
	"
fi

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	makefile_engine
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
#	vmwfs doesn't compile using gcc4 yet	
	if [ $effectiveTargetArchitecture = x86_gcc2 ]; then
		make -C vmware_fs $jobArgs OBJ_DIR=objects
	fi
	make -C vmware_mouse $jobArgs OBJ_DIR=objects
	make -C vmware_tray $jobArgs OBJ_DIR=objects
	make -C vmware_video/accelerant $jobArgs OBJ_DIR=objects
	make -C vmware_video/kernel $jobArgs OBJ_DIR=objects
	cd enhanced_backdoor
	make
}

INSTALL()
{
	if [ $effectiveTargetArchitecture = x86_gcc2 ]; then	
		mkdir -p $prefix/add-ons/kernel/file_systems
		cp vmware_fs/objects/vmwfs $prefix/add-ons/kernel/file_systems
	fi
	mkdir -p $prefix/add-ons/input_server/filters
	cp vmware_mouse/objects/vmware_mouse $prefix/add-ons/input_server/filters

	mkdir -p $binDir
	cp vmware_tray/objects/vmware_tray $binDir
	cp enhanced_backdoor/run_backdoor $binDir

	mkdir -p $prefix/add-ons/accelerants
	cp vmware_video/accelerant/objects/vmware.accelerant $prefix/add-ons/accelerants
	
	mkdir -p $prefix/add-ons/kernel/drivers/bin
	cp vmware_video/kernel/objects/vmware $prefix/add-ons/kernel/drivers/bin

	mkdir -p $prefix/add-ons/kernel/drivers/dev/graphics
	cd $prefix/add-ons/kernel/drivers/dev/graphics
	ln -s ../../bin/vmware .
	
	# Add a symlink to the Desktop applets directory in Deskbar
	desktopAppletsDir="$dataDir/deskbar/menu/Desktop applets"
	mkdir -p "$desktopAppletsDir"
	ln -s $binDir/vmware_tray "$desktopAppletsDir/VMware add-ons"
}
