SUMMARY="3D Creation/Animation/Publishing System"
DESCRIPTION="
Blender is the free and open source 3D creation suite. It supports the entirety \
of the 3D pipeline—modeling, rigging, animation, simulation, rendering, \
compositing and motion tracking, even video editing and game creation. \
Advanced users employ Blender’s API for Python scripting to customize the \
application and write specialized tools; often these are included in Blender’s \
future releases. Blender is well suited to individuals and small studios who \
benefit from its unified pipeline and responsive development process.
"
HOMEPAGE="http://www.blender.org" 
SOURCE_URI="http://download.blender.org/source/blender-$portVersion.tar.gz"
CHECKSUM_SHA256="0ca3ceb6c656ae7c556f81ab0994e6aa7a6c64324824cbc94a87caf36f0a119d"
REVISION="1"
LICENSE="GNU GPL v2"
COPYRIGHT="2002-2009 Blender Foundation"
ARCHITECTURES="!x86 x86_64"

PATCHES="blender-$portVersion.patchset"

PROVIDES="
	blender = $portVersion compat >= 2
	cmd:blender
	cmd:blender_thumbnailer.py
	"

REQUIRES="
	haiku
	lib:libfreetype$secondaryArchSuffix
	lib:libgl$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libglu$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libopenimageio$secondaryArchSuffix
	lib:libpython3.4m$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	lib:libgcc_s$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libgl$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:libopenimageio$secondaryArchSuffix
	devel:libpython3.4m$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	python3_numpy
	cmd:python3.4
	cmd:cmake
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build_haiku
	make $jobArgs BUILD_DIR=`pwd`/build_haiku \
		BUILD_CMAKE_ARGS="-DPYTHON_INCLUDE_DIR=/system/develop/headers/python3.4m/ \
		-DPYTHON_LIBRARY=/system/lib/libpython3.4m.so.1.0 \
		-DPYTHON_EXECUTABLE=/bin/python3.4 \
		-DWITH_CYCLES=OFF \
		-DWITH_BOOST=OFF \
		-DWITH_PYTHON_INSTALL=OFF \
		-DCMAKE_INSTALL_PREFIX:PATH=$prefix"
}

INSTALL()
{
	cd build_haiku
	make install
	
	mkdir -p $binDir $dataDir $docDir $appsDir
	mv $prefix/blender $prefix/blender-thumbnailer.py $binDir/
	mv $prefix/GPL-license.txt $prefix/LICENSE-bfont.ttf.txt \
		$prefix/Python-license.txt $prefix/copyright.txt $prefix/readme.html \
		$prefix/blender.svg $docDir
	mv $prefix/2.74/* $dataDir/
	mv $prefix/blender.desktop $appsDir/
	rmdir $prefix/2.74
}
