easyblock = 'ConfigureMake'

name = 'Mesa'
version = '11.0.8'

homepage = 'http://www.mesa3d.org/'
description = """Mesa is an open-source implementation of the OpenGL specification -
 a system for rendering interactive 3D graphics."""

toolchain = {'name': 'foss', 'version': '2015g'}
toolchainopts = {'optarch': True}

sources = [SOURCELOWER_TAR_GZ]
source_urls = [
    'ftp://ftp.freedesktop.org/pub/mesa/%(version)s',
    'ftp://ftp.freedesktop.org/pub/mesa/older-versions/%(version_major)s.x/%(version)s',
]

pythonver = '2.7.9'
pythonshortver = '.'.join(pythonver.split('.')[0:2])
versionsuffix = '-%s-%s' % ('Python', pythonver)

builddependencies = [
    ('flex', '2.5.39'),
    ('Bison', '3.0.2'),
    ('Autotools', '20150215', '', ('GNU', '4.9.3-2.25')),
    ('pkg-config', '0.27.1'),
    ('glproto', '1.4.16'),
    ('kbproto', '1.0.6'),
    ('xextproto', '7.3.0'),
    ('xproto', '7.0.26'),
    ('makedepend', '1.0.4'),
]

dependencies = [
    ('Python', pythonver),
    ('libxml2', '2.9.2', versionsuffix),
    ('libdrm', '2.4.27'),
    ('libX11', '1.6.2', versionsuffix),
    ('libXext', '1.3.3', versionsuffix),
    ('libXfixes', '5.0.1'),
    ('libXdamage', '1.1.4', versionsuffix),
    ('libXfont', '1.5.1', versionsuffix),
    ('LLVM', '3.7.1'),
    #('eudev', '3.1.5'),
]

# Use the os provided libudev or the EB provided eudev
#osdependencies = ['libudev']

# GLU is not part anymore of Mesa package!
#configopts = " --disable-osmesa --enable-gallium-osmesa --enable-gallium-llvm --enable-glx --disable-dri --enable-xlib-glx"
#configopts += " --disable-driglx-direct --with-gallium-drivers='swrast' --disable-egl --with-osmesa-bits=32 --enable-texture-float "

#configopts = "--disable-xvmc --disable-glx --disable-dri --with-dri-drivers= --with-gallium-drivers=swrast --enable-texture-float --disable-shared-glapi --disable-egl"
#configopts += " --with-egl-platforms= --enable-gallium-osmesa --enable-gallium-llvm=yes --with-llvm-shared-libs"

configopts = "--enable-osmesa --disable-driglx-direct --disable-dri --with-gallium-drivers=swrast --enable-gallium-llvm --disable-egl --enable-glx-tls"

# package-config files for os dependencies are in an os specific place
#preconfigopts = 'libtoolize && PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib64/pkgconfig/:/usr/share/pkgconfig" '
preconfigopts = ' libtoolize &&  '

prebuildopts = 'CPATH="$EBROOTLIBDRM/include/libdrm" '

sanity_check_paths = {
    'files': ['lib/libOSMesa.so',
              'lib/libGLESv1_CM.so', 'lib/libGLESv2.so',
              'include/GL/glext.h', 'include/GL/gl_mangle.h',
              'include/GL/glx.h', 'include/GL/osmesa.h',
              'include/GL/wglext.h', 'include/GL/gl.h',
              'include/GL/glxext.h', 'include/GL/glx_mangle.h',
              'include/GLES/gl.h', 'include/GLES2/gl2.h',
              'include/GLES3/gl3.h'],
    'dirs': []
}

maxparallel = 1

moduleclass = 'vis'
