# Automatically converted from Mesa-17.2.4-intel-2017b.eb
# Original message:
# the purpose of the easyconfig is to build a Mesa for software rendering,
# not hardware rendering. This means you want at least SSE4.2. We build:
# - llvmpipe: the high-performance Gallium LLVM driver
# - swr: Intel's OpenSWR
# it will try to use the llvmpipe by default. It you want swr, do:
# GALLIUM_DRIVER=swr

easyblock = 'MesonNinja'

name = 'Mesa'
version = '19.0.1'

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': 'GCCcore', 'version': '8.2.0'}
# Intel's SWR generates AVX instructions even on CPUs without support for it (ignoring march=native).
# In that case it is necessary to explicitly set the march of your CPU, for instance for an AMD Opteron 6100
# toolchainopts = {'optarch': 'march=barcelona'}

source_urls = [
    'https://mesa.freedesktop.org/archive/',
    'https://mesa.freedesktop.org/archive/%(version)s',
    'ftp://ftp.freedesktop.org/pub/mesa/%(version)s',
    'ftp://ftp.freedesktop.org/pub/mesa/older-versions/%(version_major)s.x/%(version)s',
]
sources = [SOURCELOWER_TAR_XZ]
checksums = [
    '6884163c0ea9e4c98378ab8fecd72fe7b5f437713a14471beda378df247999d4',  # mesa-19.0.1.tar.xz
]

builddependencies = [
    ('binutils', '2.31.1'),
    ('Meson', '0.50.0', '-Python-3.7.2'),
    ('Ninja', '1.9.0'),
    ('flex', '2.6.4'),
    ('Bison', '3.0.5'),
    ('pkg-config', '0.29.2'),
    ('Mako', '1.0.8'),
    ('libxml2', '2.9.8'),
    ('expat', '2.2.6'),
    ('gettext', '0.19.8.1'),
]

dependencies = [
    ('zlib', '1.2.11'),
    ('nettle', '3.4.1'),
    ('libdrm', '2.4.97'),
    ('LLVM', '7.0.1'),
    ('X11', '20190311'),
    ('libunwind', '1.3.1'),
]

configopts = " -Dplatforms=x11 -Dosmesa=gallium -Ddri3=false -Ddri-drivers='' -Dvulkan-drivers=''"
configopts += " -Dgbm=false -Dglx-direct=false -Dgallium-drivers='swrast,swr' -Degl=false"
configopts += " -Dllvm=true -Dshared-llvm=true"
configopts += " -Dlibunwind=true -Dglx=gallium-xlib"

sanity_check_paths = {
    'files': ['lib/libGL.%s' % SHLIB_EXT, 'lib/libOSMesa.%s' % SHLIB_EXT,
              'lib/libGLESv1_CM.%s' % SHLIB_EXT, 'lib/libGLESv2.%s' % SHLIB_EXT,
              'include/GL/glext.h', 'include/GL/gl_mangle.h',
              'include/GL/glx.h', 'include/GL/osmesa.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': []
}

moduleclass = 'vis'
