easyblock = 'CMakeMake'

name = 'Blender'
version = '2.77a'
versionsuffix = '-Python-%(pyver)s'

homepage = 'https://www.blender.org/'
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."""

toolchain = {'name': 'intel', 'version': '2016b'}

sources = [SOURCELOWER_TAR_GZ]
source_urls = ['http://download.blender.org/source/']
patches = ['Blender-%(version)s_fix-ARRAY_SIZE-icc.patch']

# disable SSE detection to give EasyBuild full control over optimization compiler flags being used
configopts = '-DWITH_CPU_SSE=OFF -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" '

# these are needed until extra dependencies are added for them to work
configopts += '-DWITH_INSTALL_PORTABLE=OFF '
configopts += '-DWITH_BUILDINFO=OFF '
configopts += '-DWITH_GAMEENGINE=OFF '
configopts += '-DWITH_SYSTEM_GLEW=OFF '

# Python paths
configopts += '-DPYTHON_VERSION=%(pyshortver)s -DPYTHON_LIBRARY=${EBROOTPYTHON}/lib/libpython%(pyshortver)sm.so '
configopts += '-DPYTHON_INCLUDE_DIR=${EBROOTPYTHON}/include/python%(pyshortver)sm '
configopts += '-DOPENEXR_INCLUDE_DIR=$EBROOTOPENEXR/include '

dependencies = [
    ('Python', '3.5.2'),
    ('Boost', '1.61.0'),
    ('libjpeg-turbo', '1.5.0'),
    ('zlib', '1.2.8'),
    ('X11', '20160819'),
    ('Mesa', '12.0.2'),
    ('OpenImageIO', '1.6.17'),  # required for cycles render engine
]

builddependencies = [('CMake', '3.6.1')]

separate_build_dir = 'True'

modextravars = {'GALLIUM_DRIVER': 'swr'}

sanity_check_paths = {
	'files': ['bin/blender'],
	'dirs': []
}

moduleclass = 'vis'
