meson.build revision 53c12917
101e04c3fSmrg# Copyright © 2017-2019 Intel Corporation
201e04c3fSmrg
301e04c3fSmrg# Permission is hereby granted, free of charge, to any person obtaining a copy
401e04c3fSmrg# of this software and associated documentation files (the "Software"), to deal
501e04c3fSmrg# in the Software without restriction, including without limitation the rights
601e04c3fSmrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
701e04c3fSmrg# copies of the Software, and to permit persons to whom the Software is
801e04c3fSmrg# furnished to do so, subject to the following conditions:
901e04c3fSmrg
1001e04c3fSmrg# The above copyright notice and this permission notice shall be included in
1101e04c3fSmrg# all copies or substantial portions of the Software.
1201e04c3fSmrg
1301e04c3fSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1401e04c3fSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1501e04c3fSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1601e04c3fSmrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1701e04c3fSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1801e04c3fSmrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1901e04c3fSmrg# SOFTWARE.
2001e04c3fSmrg
2101e04c3fSmrgproject(
2201e04c3fSmrg  'mesa',
2301e04c3fSmrg  ['c', 'cpp'],
2401e04c3fSmrg  version : run_command(
2501e04c3fSmrg    [find_program('python', 'python2', 'python3'), 'bin/meson_get_version.py']
2601e04c3fSmrg  ).stdout(),
2701e04c3fSmrg  license : 'MIT',
2801e04c3fSmrg  meson_version : '>= 0.45',
2901e04c3fSmrg  default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c99', 'cpp_std=c++11']
3001e04c3fSmrg)
3101e04c3fSmrg
3201e04c3fSmrgcc = meson.get_compiler('c')
3301e04c3fSmrgcpp = meson.get_compiler('cpp')
3401e04c3fSmrg
3501e04c3fSmrgnull_dep = dependency('', required : false)
3601e04c3fSmrg
3701e04c3fSmrg# Arguments for the preprocessor, put these in a separate array from the C and
3801e04c3fSmrg# C++ (cpp in meson terminology) arguments since they need to be added to the
3901e04c3fSmrg# default arguments for both C and C++.
4001e04c3fSmrgpre_args = [
4101e04c3fSmrg  '-D__STDC_CONSTANT_MACROS',
4201e04c3fSmrg  '-D__STDC_FORMAT_MACROS',
4301e04c3fSmrg  '-D__STDC_LIMIT_MACROS',
4453c12917Smaya  '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
4501e04c3fSmrg  '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"',
4601e04c3fSmrg]
4701e04c3fSmrg
4801e04c3fSmrgwith_vulkan_icd_dir = get_option('vulkan-icd-dir')
4901e04c3fSmrgwith_tests = get_option('build-tests')
5001e04c3fSmrgwith_valgrind = get_option('valgrind')
5101e04c3fSmrgwith_libunwind = get_option('libunwind')
5201e04c3fSmrgwith_asm = get_option('asm')
5301e04c3fSmrgwith_glx_read_only_text = get_option('glx-read-only-text')
5401e04c3fSmrgwith_glx_direct = get_option('glx-direct')
5501e04c3fSmrgwith_osmesa = get_option('osmesa')
5601e04c3fSmrgwith_swr_arches = get_option('swr-arches')
5701e04c3fSmrgwith_tools = get_option('tools')
5801e04c3fSmrgif with_tools.contains('all')
5953c12917Smaya  with_tools = ['etnaviv', 'freedreno', 'glsl', 'intel', 'nir', 'nouveau', 'xvmc']
6001e04c3fSmrgendif
6101e04c3fSmrg
6201e04c3fSmrgdri_drivers_path = get_option('dri-drivers-path')
6301e04c3fSmrgif dri_drivers_path == ''
64993e1d59Smrg  dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
6501e04c3fSmrgendif
6601e04c3fSmrgdri_search_path = get_option('dri-search-path')
6701e04c3fSmrgif dri_search_path == ''
68993e1d59Smrg  dri_search_path = dri_drivers_path
6901e04c3fSmrgendif
7001e04c3fSmrg
7101e04c3fSmrgwith_gles1 = get_option('gles1')
7201e04c3fSmrgwith_gles2 = get_option('gles2')
7353c12917Smayaif host_machine.system() == 'windows'
7453c12917Smaya  if with_gles1 == 'auto'
7553c12917Smaya    with_gles1 = 'false'
7653c12917Smaya  endif
7753c12917Smaya  if with_gles2 == 'auto'
7853c12917Smaya    with_gles2 = 'false'
7953c12917Smaya  endif
8053c12917Smayaendif
8101e04c3fSmrgwith_opengl = get_option('opengl')
8253c12917Smayawith_shared_glapi = get_option('shared-glapi')
8301e04c3fSmrg
8401e04c3fSmrg# shared-glapi is required if at least two OpenGL APIs are being built
8501e04c3fSmrgif not with_shared_glapi
8653c12917Smaya  if ((with_gles1 == 'true' and with_gles2 == 'true') or 
8753c12917Smaya      (with_gles1 == 'true' and with_opengl) or
8853c12917Smaya      (with_gles2 == 'true' and with_opengl))
8901e04c3fSmrg    error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
9001e04c3fSmrg  endif
9153c12917Smaya  with_gles1 = 'false'
9253c12917Smaya  with_gles2 = 'false'
9301e04c3fSmrgendif
9401e04c3fSmrg
9501e04c3fSmrg# We require OpenGL for OpenGL ES
9653c12917Smayaif not with_opengl
9753c12917Smaya  if (with_gles1 == 'true' or with_gles2 == 'true') and not with_opengl
9853c12917Smaya    error('building OpenGL ES without OpenGL is not supported.')
9953c12917Smaya  endif
10053c12917Smaya  with_gles1 = 'false'
10153c12917Smaya  with_gles2 = 'false'
10201e04c3fSmrgendif
10301e04c3fSmrg
10453c12917Smayawith_gles1 = with_gles1 != 'false'
10553c12917Smayawith_gles2 = with_gles2 != 'false'
10653c12917Smayawith_any_opengl = with_opengl or with_gles1 or with_gles2
10753c12917Smaya# Only build shared_glapi if at least one OpenGL API is enabled
10853c12917Smayawith_shared_glapi = get_option('shared-glapi') and with_any_opengl
10953c12917Smaya
11053c12917Smayasystem_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux'].contains(host_machine.system())
11101e04c3fSmrg
11253c12917Smayadri_drivers = get_option('dri-drivers')
11353c12917Smayaif dri_drivers.contains('auto')
11401e04c3fSmrg  if system_has_kms_drm
11501e04c3fSmrg    # TODO: PPC, Sparc
11601e04c3fSmrg    if ['x86', 'x86_64'].contains(host_machine.cpu_family())
11753c12917Smaya      dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau']
11801e04c3fSmrg    elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
11953c12917Smaya      dri_drivers = []
12001e04c3fSmrg    else
12101e04c3fSmrg      error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
12201e04c3fSmrg            host_machine.cpu_family()))
12301e04c3fSmrg    endif
12401e04c3fSmrg  elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
12501e04c3fSmrg    # only swrast would make sense here, but gallium swrast is a much better default
12653c12917Smaya    dri_drivers = []
12701e04c3fSmrg  else
12801e04c3fSmrg    error('Unknown OS @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
12901e04c3fSmrg          host_machine.system()))
13001e04c3fSmrg  endif
13101e04c3fSmrgendif
13201e04c3fSmrg
13353c12917Smayawith_dri_i915 = dri_drivers.contains('i915')
13453c12917Smayawith_dri_i965 = dri_drivers.contains('i965')
13553c12917Smayawith_dri_r100 = dri_drivers.contains('r100')
13653c12917Smayawith_dri_r200 = dri_drivers.contains('r200')
13753c12917Smayawith_dri_nouveau = dri_drivers.contains('nouveau')
13853c12917Smayawith_dri_swrast = dri_drivers.contains('swrast')
13901e04c3fSmrg
14053c12917Smayawith_dri = dri_drivers.length() != 0 and dri_drivers != ['']
14101e04c3fSmrg
14253c12917Smayagallium_drivers = get_option('gallium-drivers')
14353c12917Smayaif gallium_drivers.contains('auto')
14401e04c3fSmrg  if system_has_kms_drm
14501e04c3fSmrg    # TODO: PPC, Sparc
14601e04c3fSmrg    if ['x86', 'x86_64'].contains(host_machine.cpu_family())
14753c12917Smaya      gallium_drivers = [
14801e04c3fSmrg        'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast'
14901e04c3fSmrg      ]
15001e04c3fSmrg    elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
15153c12917Smaya      gallium_drivers = [
15253c12917Smaya        'kmsro', 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau',
15353c12917Smaya        'tegra', 'virgl', 'lima', 'swrast'
15401e04c3fSmrg      ]
15501e04c3fSmrg    else
15601e04c3fSmrg      error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
15701e04c3fSmrg            host_machine.cpu_family()))
15801e04c3fSmrg    endif
15901e04c3fSmrg  elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
16053c12917Smaya    gallium_drivers = ['swrast']
16101e04c3fSmrg  else
16201e04c3fSmrg    error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
16301e04c3fSmrg          host_machine.system()))
16401e04c3fSmrg  endif
16501e04c3fSmrgendif
16653c12917Smayawith_gallium_kmsro = gallium_drivers.contains('kmsro')
16753c12917Smayawith_gallium_radeonsi = gallium_drivers.contains('radeonsi')
16853c12917Smayawith_gallium_r300 = gallium_drivers.contains('r300')
16953c12917Smayawith_gallium_r600 = gallium_drivers.contains('r600')
17053c12917Smayawith_gallium_nouveau = gallium_drivers.contains('nouveau')
17153c12917Smayawith_gallium_freedreno = gallium_drivers.contains('freedreno')
17253c12917Smayawith_gallium_softpipe = gallium_drivers.contains('swrast')
17353c12917Smayawith_gallium_vc4 = gallium_drivers.contains('vc4')
17453c12917Smayawith_gallium_v3d = gallium_drivers.contains('v3d')
17553c12917Smayawith_gallium_panfrost = gallium_drivers.contains('panfrost')
17653c12917Smayawith_gallium_etnaviv = gallium_drivers.contains('etnaviv')
17753c12917Smayawith_gallium_tegra = gallium_drivers.contains('tegra')
17853c12917Smayawith_gallium_iris = gallium_drivers.contains('iris')
17953c12917Smayawith_gallium_i915 = gallium_drivers.contains('i915')
18053c12917Smayawith_gallium_svga = gallium_drivers.contains('svga')
18153c12917Smayawith_gallium_virgl = gallium_drivers.contains('virgl')
18253c12917Smayawith_gallium_swr = gallium_drivers.contains('swr')
18353c12917Smayawith_gallium_lima = gallium_drivers.contains('lima')
18401e04c3fSmrg
18501e04c3fSmrgif cc.get_id() == 'intel'
18601e04c3fSmrg  if meson.version().version_compare('< 0.49.0')
18701e04c3fSmrg    error('Meson does not have sufficient support of ICC before 0.49.0 to compile mesa')
18801e04c3fSmrg  elif with_gallium_swr and meson.version().version_compare('== 0.49.0')
18901e04c3fSmrg    warning('Meson as of 0.49.0 is sufficient for compiling mesa with ICC, but there are some caveats with SWR. 0.49.1 should resolve all of these')
19001e04c3fSmrg  endif
19101e04c3fSmrgendif
19201e04c3fSmrg
19353c12917Smaya#This message is needed until we bump meson version to 0.46 because of known 0.45.0 and 0.45.1 issue
19453c12917Smaya#https://bugs.freedesktop.org/show_bug.cgi?id=109791
19553c12917Smayaif meson.version().version_compare('< 0.46.0')
19653c12917Smaya    warning('''Meson < 0.46 doesn't automatically define `NDEBUG`; please update meson to at least 0.46.''')
19753c12917Smayaendif
19853c12917Smaya
19953c12917Smayawith_gallium = gallium_drivers.length() != 0 and gallium_drivers != ['']
20001e04c3fSmrg
20101e04c3fSmrgif with_gallium and system_has_kms_drm
20201e04c3fSmrg  _glx = get_option('glx')
20301e04c3fSmrg  _egl = get_option('egl')
20401e04c3fSmrg  if _glx == 'dri' or _egl == 'true' or (_glx == 'disabled' and _egl != 'false')
20501e04c3fSmrg    with_dri = true
20601e04c3fSmrg  endif
20701e04c3fSmrgendif
20801e04c3fSmrg
20901e04c3fSmrg_vulkan_drivers = get_option('vulkan-drivers')
21001e04c3fSmrgif _vulkan_drivers.contains('auto')
21101e04c3fSmrg  if system_has_kms_drm
21201e04c3fSmrg    if host_machine.cpu_family().startswith('x86')
21301e04c3fSmrg      _vulkan_drivers = ['amd', 'intel']
21401e04c3fSmrg    elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
21501e04c3fSmrg      _vulkan_drivers = []
21601e04c3fSmrg    else
21701e04c3fSmrg      error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
21801e04c3fSmrg            host_machine.cpu_family()))
21901e04c3fSmrg    endif
22001e04c3fSmrg  elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
22101e04c3fSmrg    # No vulkan driver supports windows or macOS currently
22201e04c3fSmrg    _vulkan_drivers = []
22301e04c3fSmrg  else
22401e04c3fSmrg    error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
22501e04c3fSmrg          host_machine.system()))
22601e04c3fSmrg  endif
22701e04c3fSmrgendif
22801e04c3fSmrg
22901e04c3fSmrgwith_intel_vk = _vulkan_drivers.contains('intel')
23001e04c3fSmrgwith_amd_vk = _vulkan_drivers.contains('amd')
23153c12917Smayawith_freedreno_vk = _vulkan_drivers.contains('freedreno')
23201e04c3fSmrgwith_any_vk = _vulkan_drivers.length() != 0 and _vulkan_drivers != ['']
23301e04c3fSmrg
23453c12917Smayaif with_freedreno_vk and get_option('I-love-half-baked-turnips') != true
23553c12917Smaya  error('Cannot enable freedreno vulkan driver')
23653c12917Smayaendif
23753c12917Smaya
23801e04c3fSmrgif with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
23901e04c3fSmrg  error('Only one swrast provider can be built')
24001e04c3fSmrgendif
24101e04c3fSmrgif with_dri_i915 and with_gallium_i915
24201e04c3fSmrg  error('Only one i915 provider can be built')
24301e04c3fSmrgendif
24453c12917Smayaif with_gallium_kmsro and not (with_gallium_v3d or with_gallium_vc4 or with_gallium_etnaviv or with_gallium_freedreno or with_gallium_panfrost or with_gallium_lima)
24553c12917Smaya  error('kmsro driver requires one or more renderonly drivers (vc4, etnaviv, freedreno, panfrost, lima)')
24601e04c3fSmrgendif
24701e04c3fSmrgif with_gallium_tegra and not with_gallium_nouveau
24801e04c3fSmrg  error('tegra driver requires nouveau driver')
24901e04c3fSmrgendif
25001e04c3fSmrg
25101e04c3fSmrgif host_machine.system() == 'darwin'
25201e04c3fSmrg  with_dri_platform = 'apple'
25353c12917Smaya  pre_args += '-DBUILDING_MESA'
25401e04c3fSmrgelif ['windows', 'cygwin'].contains(host_machine.system())
25501e04c3fSmrg  with_dri_platform = 'windows'
25601e04c3fSmrgelif system_has_kms_drm
25701e04c3fSmrg  with_dri_platform = 'drm'
25801e04c3fSmrgelse
25901e04c3fSmrg  # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
26001e04c3fSmrg  # assert here that one of those cases has been met.
26101e04c3fSmrg  # FIXME: illumos ends up here as well
26201e04c3fSmrg  with_dri_platform = 'none'
26301e04c3fSmrgendif
26401e04c3fSmrg
26501e04c3fSmrg_platforms = get_option('platforms')
26601e04c3fSmrgif _platforms.contains('auto')
26701e04c3fSmrg  if system_has_kms_drm
26801e04c3fSmrg    _platforms = ['x11', 'wayland', 'drm', 'surfaceless']
26901e04c3fSmrg  elif ['darwin', 'windows', 'cygwin'].contains(host_machine.system())
27001e04c3fSmrg    _platforms = ['x11', 'surfaceless']
27101e04c3fSmrg  elif ['haiku'].contains(host_machine.system())
27201e04c3fSmrg    _platforms = ['haiku']
27301e04c3fSmrg  else
27401e04c3fSmrg    error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format(
27501e04c3fSmrg          host_machine.system()))
27601e04c3fSmrg  endif
27701e04c3fSmrgendif
27801e04c3fSmrg
27901e04c3fSmrgwith_platform_android = _platforms.contains('android')
28001e04c3fSmrgwith_platform_x11 = _platforms.contains('x11')
28101e04c3fSmrgwith_platform_wayland = _platforms.contains('wayland')
28201e04c3fSmrgwith_platform_drm = _platforms.contains('drm')
28301e04c3fSmrgwith_platform_haiku = _platforms.contains('haiku')
28401e04c3fSmrgwith_platform_surfaceless = _platforms.contains('surfaceless')
28501e04c3fSmrg
28601e04c3fSmrgwith_platforms = false
28701e04c3fSmrgif _platforms.length() != 0 and _platforms != ['']
28801e04c3fSmrg  with_platforms = true
28901e04c3fSmrg  egl_native_platform = _platforms[0]
29001e04c3fSmrgendif
29101e04c3fSmrg
29201e04c3fSmrg_xlib_lease = get_option('xlib-lease')
29301e04c3fSmrgif _xlib_lease == 'auto'
29401e04c3fSmrg  with_xlib_lease = with_platform_x11 and with_platform_drm
29501e04c3fSmrgelse
29601e04c3fSmrg  with_xlib_lease = _xlib_lease == 'true'
29701e04c3fSmrgendif
29801e04c3fSmrg
29901e04c3fSmrgwith_glx = get_option('glx')
30001e04c3fSmrgif with_glx == 'auto'
30101e04c3fSmrg  if with_dri
30201e04c3fSmrg    with_glx = 'dri'
30301e04c3fSmrg  elif with_platform_haiku
30401e04c3fSmrg    with_glx = 'disabled'
30501e04c3fSmrg  elif with_gallium
30601e04c3fSmrg    # Even when building just gallium drivers the user probably wants dri
30701e04c3fSmrg    with_glx = 'dri'
30801e04c3fSmrg  elif with_platform_x11 and with_any_opengl and not with_any_vk
30901e04c3fSmrg    # The automatic behavior should not be to turn on xlib based glx when
31001e04c3fSmrg    # building only vulkan drivers
31101e04c3fSmrg    with_glx = 'xlib'
31201e04c3fSmrg  else
31301e04c3fSmrg    with_glx = 'disabled'
31401e04c3fSmrg  endif
31501e04c3fSmrgendif
31601e04c3fSmrgif with_glx == 'dri'
31701e04c3fSmrg   if with_gallium
31801e04c3fSmrg      with_dri = true
31901e04c3fSmrg   endif
32001e04c3fSmrgendif
32101e04c3fSmrg
32253c12917Smayaif not (with_dri or with_gallium or with_glx != 'disabled')
32301e04c3fSmrg  with_gles1 = false
32401e04c3fSmrg  with_gles2 = false
32501e04c3fSmrg  with_opengl = false
32601e04c3fSmrg  with_any_opengl = false
32701e04c3fSmrg  with_shared_glapi = false
32801e04c3fSmrgendif
32901e04c3fSmrg
33001e04c3fSmrg_gbm = get_option('gbm')
33101e04c3fSmrgif _gbm == 'auto'
33201e04c3fSmrg  with_gbm = system_has_kms_drm and with_dri
33301e04c3fSmrgelse
33401e04c3fSmrg  with_gbm = _gbm == 'true'
33501e04c3fSmrgendif
33601e04c3fSmrgif with_gbm and not system_has_kms_drm
33701e04c3fSmrg  error('GBM only supports DRM/KMS platforms')
33801e04c3fSmrgendif
33901e04c3fSmrg
34001e04c3fSmrg_egl = get_option('egl')
34101e04c3fSmrgif _egl == 'auto'
34201e04c3fSmrg  with_egl = (
34301e04c3fSmrg    not ['darwin', 'windows'].contains(host_machine.system()) and
34401e04c3fSmrg    with_dri and with_shared_glapi and with_platforms
34501e04c3fSmrg  )
34601e04c3fSmrgelif _egl == 'true'
34701e04c3fSmrg  if not with_dri
34801e04c3fSmrg    error('EGL requires dri')
34901e04c3fSmrg  elif not with_shared_glapi
35001e04c3fSmrg    error('EGL requires shared-glapi')
35101e04c3fSmrg  elif not with_platforms
35201e04c3fSmrg    error('No platforms specified, consider -Dplatforms=drm,x11,surfaceless at least')
35301e04c3fSmrg  elif not ['disabled', 'dri'].contains(with_glx)
35401e04c3fSmrg    error('EGL requires dri, but a GLX is being built without dri')
35501e04c3fSmrg  elif ['darwin', 'windows'].contains(host_machine.system())
35601e04c3fSmrg    error('EGL is not available on Windows or MacOS')
35701e04c3fSmrg  endif
35801e04c3fSmrg  with_egl = true
35901e04c3fSmrgelse
36001e04c3fSmrg  with_egl = false
36101e04c3fSmrgendif
36201e04c3fSmrg
36353c12917Smayaif with_egl and not (with_platform_drm or with_platform_surfaceless or with_platform_android)
36401e04c3fSmrg  if with_gallium_radeonsi
36553c12917Smaya    error('RadeonSI requires the drm, surfaceless or android platform when using EGL')
36601e04c3fSmrg  endif
36701e04c3fSmrg  if with_gallium_virgl
36853c12917Smaya    error('Virgl requires the drm, surfaceless or android platform when using EGL')
36901e04c3fSmrg  endif
37001e04c3fSmrgendif
37101e04c3fSmrg
37201e04c3fSmrgpre_args += '-DGLX_USE_TLS'
37301e04c3fSmrgif with_glx != 'disabled'
37401e04c3fSmrg  if not (with_platform_x11 and with_any_opengl)
37501e04c3fSmrg    error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
37601e04c3fSmrg  elif with_glx == 'gallium-xlib' 
37701e04c3fSmrg    if not with_gallium
37801e04c3fSmrg      error('Gallium-xlib based GLX requires at least one gallium driver')
37901e04c3fSmrg    elif not with_gallium_softpipe
38001e04c3fSmrg      error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
38101e04c3fSmrg    elif with_dri
38201e04c3fSmrg      error('gallium-xlib conflicts with any dri driver')
38301e04c3fSmrg    endif
38401e04c3fSmrg  elif with_glx == 'xlib' 
38501e04c3fSmrg    if with_dri
38601e04c3fSmrg      error('xlib conflicts with any dri driver')
38701e04c3fSmrg    endif
38801e04c3fSmrg  elif with_glx == 'dri'
38953c12917Smaya    if not with_shared_glapi
39001e04c3fSmrg      error('dri based GLX requires shared-glapi')
39101e04c3fSmrg    endif
39201e04c3fSmrg  endif
39301e04c3fSmrgendif
39401e04c3fSmrg
39501e04c3fSmrgwith_glvnd = get_option('glvnd')
39601e04c3fSmrgif with_glvnd
39701e04c3fSmrg  if with_glx == 'xlib' or with_glx == 'gallium-xlib'
39801e04c3fSmrg    error('Cannot build glvnd support for GLX that is not DRI based.')
39901e04c3fSmrg  elif with_glx == 'disabled' and not with_egl
40001e04c3fSmrg    error('glvnd requires DRI based GLX and/or EGL')
40101e04c3fSmrg  endif
40253c12917Smaya  if get_option('egl-lib-suffix') != ''
40353c12917Smaya    error('''EGL lib suffix can't be used with libglvnd''')
40453c12917Smaya  endif
40501e04c3fSmrgendif
40601e04c3fSmrg
40701e04c3fSmrgif with_vulkan_icd_dir == ''
40801e04c3fSmrg  with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
40901e04c3fSmrgendif
41001e04c3fSmrg
41153c12917Smayawith_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or
41253c12917Smaya  host_machine.system() == 'gnu')
41301e04c3fSmrg_dri3 = get_option('dri3')
41401e04c3fSmrgif _dri3 == 'auto'
41501e04c3fSmrg  with_dri3 = system_has_kms_drm and with_dri2
41601e04c3fSmrgelse
41701e04c3fSmrg  with_dri3 = _dri3 == 'true'
41801e04c3fSmrgendif
41901e04c3fSmrg
42001e04c3fSmrgif with_any_vk and (with_platform_x11 and not with_dri3)
42101e04c3fSmrg  error('Vulkan drivers require dri3 for X11 support')
42201e04c3fSmrgendif
42301e04c3fSmrgif with_dri
42401e04c3fSmrg  if with_glx == 'disabled' and not with_egl and not with_gbm and with_osmesa != 'classic'
42501e04c3fSmrg    error('building dri drivers require at least one windowing system or classic osmesa')
42601e04c3fSmrg  endif
42701e04c3fSmrgendif
42801e04c3fSmrg
42901e04c3fSmrgprog_pkgconfig = find_program('pkg-config')
43001e04c3fSmrg
43101e04c3fSmrg_vdpau = get_option('gallium-vdpau')
43201e04c3fSmrgif not system_has_kms_drm
43301e04c3fSmrg  if _vdpau == 'true'
43401e04c3fSmrg    error('VDPAU state tracker can only be build on unix-like OSes.')
43501e04c3fSmrg  else
43601e04c3fSmrg    _vdpau = 'false'
43701e04c3fSmrg  endif
43801e04c3fSmrgelif not with_platform_x11
43901e04c3fSmrg  if _vdpau == 'true'
44001e04c3fSmrg    error('VDPAU state tracker requires X11 support.')
44101e04c3fSmrg  else
44201e04c3fSmrg    _vdpau = 'false'
44301e04c3fSmrg  endif
44401e04c3fSmrgelif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
44501e04c3fSmrg          with_gallium_nouveau)
44601e04c3fSmrg  if _vdpau == 'true'
44701e04c3fSmrg    error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.')
44801e04c3fSmrg  else
44901e04c3fSmrg    _vdpau = 'false'
45001e04c3fSmrg  endif
45101e04c3fSmrgendif
45201e04c3fSmrgdep_vdpau = null_dep
45301e04c3fSmrgwith_gallium_vdpau = false
45401e04c3fSmrgif _vdpau != 'false'
45501e04c3fSmrg  dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'true')
45601e04c3fSmrg  if dep_vdpau.found()
45701e04c3fSmrg    dep_vdpau = declare_dependency(
45801e04c3fSmrg      compile_args : run_command(prog_pkgconfig, ['vdpau', '--cflags']).stdout().split()
45901e04c3fSmrg    )
46001e04c3fSmrg    with_gallium_vdpau = true
46101e04c3fSmrg  endif
46201e04c3fSmrgendif
46301e04c3fSmrg
46401e04c3fSmrgif with_gallium_vdpau
46501e04c3fSmrg  pre_args += '-DHAVE_ST_VDPAU'
46601e04c3fSmrgendif
46701e04c3fSmrgvdpau_drivers_path = get_option('vdpau-libs-path')
46801e04c3fSmrgif vdpau_drivers_path == ''
46901e04c3fSmrg  vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
47001e04c3fSmrgendif
47101e04c3fSmrg
47201e04c3fSmrg_xvmc = get_option('gallium-xvmc')
47301e04c3fSmrgif not system_has_kms_drm
47401e04c3fSmrg  if _xvmc == 'true'
47501e04c3fSmrg    error('XVMC state tracker can only be build on unix-like OSes.')
47601e04c3fSmrg  else
47701e04c3fSmrg    _xvmc = 'false'
47801e04c3fSmrg  endif
47901e04c3fSmrgelif not with_platform_x11
48001e04c3fSmrg  if _xvmc == 'true'
48101e04c3fSmrg    error('XVMC state tracker requires X11 support.')
48201e04c3fSmrg  else
48301e04c3fSmrg    _xvmc = 'false'
48401e04c3fSmrg  endif
48501e04c3fSmrgelif not (with_gallium_r600 or with_gallium_nouveau)
48601e04c3fSmrg  if _xvmc == 'true'
48701e04c3fSmrg    error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.')
48801e04c3fSmrg  else
48901e04c3fSmrg    _xvmc = 'false'
49001e04c3fSmrg  endif
49101e04c3fSmrgendif
49201e04c3fSmrgdep_xvmc = null_dep
49301e04c3fSmrgwith_gallium_xvmc = false
49401e04c3fSmrgif _xvmc != 'false'
49501e04c3fSmrg  dep_xvmc = dependency('xvmc', version : '>= 1.0.6', required : _xvmc == 'true')
49601e04c3fSmrg  with_gallium_xvmc = dep_xvmc.found()
49701e04c3fSmrgendif
49801e04c3fSmrg
49901e04c3fSmrgxvmc_drivers_path = get_option('xvmc-libs-path')
50001e04c3fSmrgif xvmc_drivers_path == ''
50101e04c3fSmrg  xvmc_drivers_path = get_option('libdir')
50201e04c3fSmrgendif
50301e04c3fSmrg
50401e04c3fSmrg_omx = get_option('gallium-omx')
50501e04c3fSmrgif not system_has_kms_drm
50601e04c3fSmrg  if ['auto', 'disabled'].contains(_omx)
50701e04c3fSmrg    _omx = 'disabled'
50801e04c3fSmrg  else
50901e04c3fSmrg    error('OMX state tracker can only be built on unix-like OSes.')
51001e04c3fSmrg  endif
51101e04c3fSmrgelif not (with_platform_x11 or with_platform_drm)
51201e04c3fSmrg  if ['auto', 'disabled'].contains(_omx)
51301e04c3fSmrg    _omx = 'disabled'
51401e04c3fSmrg  else
51501e04c3fSmrg    error('OMX state tracker requires X11 or drm platform support.')
51601e04c3fSmrg  endif
51701e04c3fSmrgelif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
51801e04c3fSmrg  if ['auto', 'disabled'].contains(_omx)
51901e04c3fSmrg    _omx = 'disabled'
52001e04c3fSmrg  else
52101e04c3fSmrg    error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
52201e04c3fSmrg  endif
52301e04c3fSmrgendif
52401e04c3fSmrgwith_gallium_omx = _omx
52501e04c3fSmrgdep_omx = null_dep
52601e04c3fSmrgdep_omx_other = []
52701e04c3fSmrgif ['auto', 'bellagio'].contains(_omx)
52801e04c3fSmrg  dep_omx = dependency(
52901e04c3fSmrg    'libomxil-bellagio', required : _omx == 'bellagio'
53001e04c3fSmrg  )
53101e04c3fSmrg  if dep_omx.found()
53201e04c3fSmrg    with_gallium_omx = 'bellagio'
53301e04c3fSmrg  endif
53401e04c3fSmrgendif
53501e04c3fSmrgif ['auto', 'tizonia'].contains(_omx)
53601e04c3fSmrg  if with_dri and with_egl
53701e04c3fSmrg    dep_omx = dependency(
53801e04c3fSmrg      'libtizonia', version : '>= 0.10.0',
53901e04c3fSmrg      required : _omx == 'tizonia',
54001e04c3fSmrg    )
54101e04c3fSmrg    dep_omx_other = [
54201e04c3fSmrg      dependency('libtizplatform', required : _omx == 'tizonia'),
54301e04c3fSmrg      dependency('tizilheaders', required : _omx == 'tizonia'),
54401e04c3fSmrg    ]
54501e04c3fSmrg    if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
54601e04c3fSmrg      with_gallium_omx = 'tizonia'
54701e04c3fSmrg    endif
54801e04c3fSmrg  elif _omx == 'tizonia'
54901e04c3fSmrg    error('OMX-Tizonia state tracker requires dri and egl')
55001e04c3fSmrg  endif
55101e04c3fSmrgendif
55201e04c3fSmrgif _omx == 'auto'
55301e04c3fSmrg  with_gallium_omx = 'disabled'
55401e04c3fSmrgelse
55501e04c3fSmrg  with_gallium_omx = _omx
55601e04c3fSmrgendif
55701e04c3fSmrg
55801e04c3fSmrgpre_args += [
55901e04c3fSmrg  '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'),
56001e04c3fSmrg  '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'),
56101e04c3fSmrg]
56201e04c3fSmrg
56301e04c3fSmrg
56401e04c3fSmrgomx_drivers_path = get_option('omx-libs-path')
56501e04c3fSmrg
56601e04c3fSmrgif with_gallium_omx != 'disabled'
56701e04c3fSmrg  # Figure out where to put the omx driver.
56801e04c3fSmrg  # FIXME: this could all be vastly simplified by adding a 'defined_variable'
56901e04c3fSmrg  # argument to meson's get_pkgconfig_variable method.
57001e04c3fSmrg  if omx_drivers_path == ''
57101e04c3fSmrg    _omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
57201e04c3fSmrg    _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
57301e04c3fSmrg    if _omx_libdir == get_option('libdir')
57401e04c3fSmrg      omx_drivers_path = _omx_drivers_dir
57501e04c3fSmrg    else
57601e04c3fSmrg      _omx_base_dir = []
57701e04c3fSmrg      # This will fail on windows. Does OMX run on windows?
57801e04c3fSmrg      _omx_libdir = _omx_libdir.split('/')
57901e04c3fSmrg      _omx_drivers_dir = _omx_drivers_dir.split('/')
58001e04c3fSmrg      foreach o : _omx_drivers_dir
58101e04c3fSmrg        if not _omx_libdir.contains(o)
58201e04c3fSmrg          _omx_base_dir += o
58301e04c3fSmrg        endif
58401e04c3fSmrg      endforeach
58501e04c3fSmrg      omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
58601e04c3fSmrg    endif
58701e04c3fSmrg  endif
58801e04c3fSmrgendif
58901e04c3fSmrg
59001e04c3fSmrg_va = get_option('gallium-va')
59101e04c3fSmrgif not system_has_kms_drm
59201e04c3fSmrg  if _va == 'true'
59301e04c3fSmrg    error('VA state tracker can only be built on unix-like OSes.')
59401e04c3fSmrg  else
59501e04c3fSmrg    _va = 'false'
59601e04c3fSmrg  endif
59701e04c3fSmrgelif not (with_platform_x11 or with_platform_drm)
59801e04c3fSmrg  if _va == 'true'
59901e04c3fSmrg    error('VA state tracker requires X11 or drm or wayland platform support.')
60001e04c3fSmrg  else
60101e04c3fSmrg    _va = 'false'
60201e04c3fSmrg  endif
60301e04c3fSmrgelif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
60401e04c3fSmrg  if _va == 'true'
60501e04c3fSmrg    error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
60601e04c3fSmrg  else
60701e04c3fSmrg    _va = 'false'
60801e04c3fSmrg  endif
60901e04c3fSmrgendif
61001e04c3fSmrgwith_gallium_va = false
61101e04c3fSmrgdep_va = null_dep
61201e04c3fSmrgif _va != 'false'
61301e04c3fSmrg  dep_va = dependency('libva', version : '>= 0.38.0', required : _va == 'true')
61401e04c3fSmrg  if dep_va.found()
61501e04c3fSmrg    dep_va_headers = declare_dependency(
61601e04c3fSmrg      compile_args : run_command(prog_pkgconfig, ['libva', '--cflags']).stdout().split()
61701e04c3fSmrg    )
61801e04c3fSmrg    with_gallium_va = true
61901e04c3fSmrg  endif
62001e04c3fSmrgendif
62101e04c3fSmrg
62201e04c3fSmrgva_drivers_path = get_option('va-libs-path')
62301e04c3fSmrgif va_drivers_path == ''
62401e04c3fSmrg  va_drivers_path = join_paths(get_option('libdir'), 'dri')
62501e04c3fSmrgendif
62601e04c3fSmrg
62701e04c3fSmrg_xa = get_option('gallium-xa')
62801e04c3fSmrgif not system_has_kms_drm
62901e04c3fSmrg  if _xa == 'true'
63001e04c3fSmrg    error('XA state tracker can only be built on unix-like OSes.')
63101e04c3fSmrg  else
63201e04c3fSmrg    _xa = 'false'
63301e04c3fSmrg  endif
63401e04c3fSmrgelif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
63501e04c3fSmrg          or with_gallium_svga)
63601e04c3fSmrg  if _xa == 'true'
63701e04c3fSmrg    error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.')
63801e04c3fSmrg  else
63901e04c3fSmrg    _xa = 'false'
64001e04c3fSmrg  endif
64101e04c3fSmrgendif
64201e04c3fSmrgwith_gallium_xa = _xa != 'false'
64301e04c3fSmrg
64401e04c3fSmrgd3d_drivers_path = get_option('d3d-drivers-path')
64501e04c3fSmrgif d3d_drivers_path == ''
646993e1d59Smrg  d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d')
64701e04c3fSmrgendif
64801e04c3fSmrg
64901e04c3fSmrgwith_gallium_st_nine =  get_option('gallium-nine')
65001e04c3fSmrgif with_gallium_st_nine
65101e04c3fSmrg  if not with_gallium_softpipe
65201e04c3fSmrg    error('The nine state tracker requires gallium softpipe/llvmpipe.')
65301e04c3fSmrg  elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600
65453c12917Smaya            or with_gallium_r300 or with_gallium_svga or with_gallium_i915
65553c12917Smaya            or with_gallium_iris)
65601e04c3fSmrg    error('The nine state tracker requires at least one non-swrast gallium driver.')
65701e04c3fSmrg  endif
65801e04c3fSmrg  if not with_dri3
65901e04c3fSmrg    error('Using nine with wine requires dri3')
66001e04c3fSmrg  endif
66101e04c3fSmrgendif
66201e04c3fSmrg
66301e04c3fSmrgif get_option('power8') != 'false'
66401e04c3fSmrg  # on old versions of meson the cpu family would return as ppc64le on little
66501e04c3fSmrg  # endian power8, this was changed in 0.48 such that the family would always
66601e04c3fSmrg  # be ppc64 regardless of endianness, and the the machine.endian() value
66701e04c3fSmrg  # should be checked. Since we support versions < 0.48 we need to use
66801e04c3fSmrg  # startswith.
66901e04c3fSmrg  if host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
67001e04c3fSmrg    if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
67101e04c3fSmrg      error('Altivec is not supported with gcc version < 4.8.')
67201e04c3fSmrg    endif
67301e04c3fSmrg    if cc.compiles('''
67401e04c3fSmrg        #include <altivec.h>
67501e04c3fSmrg        int main() {
67601e04c3fSmrg          vector unsigned char r;
67701e04c3fSmrg          vector unsigned int v = vec_splat_u32 (1);
67801e04c3fSmrg          r = __builtin_vec_vgbbd ((vector unsigned char) v);
67901e04c3fSmrg          return 0;
68001e04c3fSmrg        }''',
68101e04c3fSmrg        args : '-mpower8-vector',
68201e04c3fSmrg        name : 'POWER8 intrinsics')
68301e04c3fSmrg      pre_args += ['-D_ARCH_PWR8', '-mpower8-vector']
68401e04c3fSmrg    elif get_option('power8') == 'true'
68501e04c3fSmrg      error('POWER8 intrinsic support required but not found.')
68601e04c3fSmrg    endif
68701e04c3fSmrg  endif
68801e04c3fSmrgendif
68901e04c3fSmrg
69001e04c3fSmrg_opencl = get_option('gallium-opencl')
69101e04c3fSmrgclover_cpp_std = []
69201e04c3fSmrgif _opencl != 'disabled'
69301e04c3fSmrg  if not with_gallium
69401e04c3fSmrg    error('OpenCL Clover implementation requires at least one gallium driver.')
69501e04c3fSmrg  endif
69601e04c3fSmrg
69701e04c3fSmrg  dep_clc = dependency('libclc')
69801e04c3fSmrg  with_gallium_opencl = true
69901e04c3fSmrg  with_opencl_icd = _opencl == 'icd'
70001e04c3fSmrg
70101e04c3fSmrg  if host_machine.cpu_family().startswith('ppc') and cpp.compiles('''
70201e04c3fSmrg      #if !defined(__VEC__) || !defined(__ALTIVEC__)
70301e04c3fSmrg      #error "AltiVec not enabled"
70401e04c3fSmrg      #endif''',
70501e04c3fSmrg      name : 'Altivec')
70601e04c3fSmrg    clover_cpp_std += ['cpp_std=gnu++11']
70701e04c3fSmrg  endif
70801e04c3fSmrgelse
70901e04c3fSmrg  dep_clc = null_dep
71001e04c3fSmrg  with_gallium_opencl = false
71101e04c3fSmrg  with_opencl_icd = false
71201e04c3fSmrgendif
71301e04c3fSmrg
71401e04c3fSmrggl_pkgconfig_c_flags = []
71501e04c3fSmrgif with_platform_x11
71601e04c3fSmrg  if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
71701e04c3fSmrg    pre_args += '-DHAVE_X11_PLATFORM'
71801e04c3fSmrg  endif
71901e04c3fSmrg  if with_glx == 'xlib' or with_glx == 'gallium-xlib'
72001e04c3fSmrg    pre_args += '-DUSE_XSHM'
72101e04c3fSmrg  else
72201e04c3fSmrg    pre_args += '-DGLX_INDIRECT_RENDERING'
72301e04c3fSmrg    if with_glx_direct
72401e04c3fSmrg      pre_args += '-DGLX_DIRECT_RENDERING'
72501e04c3fSmrg    endif
72601e04c3fSmrg    if with_dri_platform == 'drm'
72701e04c3fSmrg      pre_args += '-DGLX_USE_DRM'
72801e04c3fSmrg    elif with_dri_platform == 'apple'
72901e04c3fSmrg      pre_args += '-DGLX_USE_APPLEGL'
73001e04c3fSmrg    elif with_dri_platform == 'windows'
73101e04c3fSmrg      pre_args += '-DGLX_USE_WINDOWSGL'
73201e04c3fSmrg    endif
73301e04c3fSmrg  endif
73401e04c3fSmrgelse
73501e04c3fSmrg  pre_args += '-DMESA_EGL_NO_X11_HEADERS'
73601e04c3fSmrg  gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS'
73701e04c3fSmrgendif
73801e04c3fSmrgif with_platform_drm
73901e04c3fSmrg  if with_egl and not with_gbm
74001e04c3fSmrg    error('EGL drm platform requires gbm')
74101e04c3fSmrg  endif
74201e04c3fSmrg  pre_args += '-DHAVE_DRM_PLATFORM'
74301e04c3fSmrgendif
74401e04c3fSmrgif with_platform_surfaceless
74501e04c3fSmrg  pre_args += '-DHAVE_SURFACELESS_PLATFORM'
74601e04c3fSmrgendif
74701e04c3fSmrgif with_platform_android
74801e04c3fSmrg  dep_android = [
74901e04c3fSmrg    dependency('cutils'),
75001e04c3fSmrg    dependency('hardware'),
75101e04c3fSmrg    dependency('sync'),
75201e04c3fSmrg  ]
75353c12917Smaya  if get_option('platform-sdk-version') >= 26
75453c12917Smaya    dep_android += dependency('nativewindow')
75553c12917Smaya  endif
75601e04c3fSmrg  pre_args += '-DHAVE_ANDROID_PLATFORM'
75701e04c3fSmrgendif
75801e04c3fSmrgif with_platform_haiku
75901e04c3fSmrg  pre_args += '-DHAVE_HAIKU_PLATFORM'
76001e04c3fSmrgendif
76101e04c3fSmrg
76253c12917Smayaif meson.version().version_compare('>=0.50')
76353c12917Smaya  prog_python = import('python').find_installation('python3')
76453c12917Smayaelse
76553c12917Smaya  prog_python = import('python3').find_python()
76653c12917Smayaendif
76701e04c3fSmrghas_mako = run_command(
76801e04c3fSmrg  prog_python, '-c',
76901e04c3fSmrg  '''
77001e04c3fSmrgfrom distutils.version import StrictVersion
77101e04c3fSmrgimport mako
77201e04c3fSmrgassert StrictVersion(mako.__version__) > StrictVersion("0.8.0")
77301e04c3fSmrg  ''')
77401e04c3fSmrgif has_mako.returncode() != 0
77501e04c3fSmrg  error('Python (3.x) mako module >= 0.8.0 required to build mesa.')
77601e04c3fSmrgendif
77701e04c3fSmrg
77801e04c3fSmrgif cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
77901e04c3fSmrg  error('When using GCC, version 4.4.6 or later is required.')
78001e04c3fSmrgendif
78101e04c3fSmrg
78201e04c3fSmrg# Define DEBUG for debug builds only (debugoptimized is not included on this one)
78301e04c3fSmrgif get_option('buildtype') == 'debug'
78401e04c3fSmrg  pre_args += '-DDEBUG'
78501e04c3fSmrgendif
78601e04c3fSmrg
78753c12917Smayawith_shader_cache = false
78853c12917Smaya_shader_cache = get_option('shader-cache')
78953c12917Smayaif _shader_cache != 'false'
79053c12917Smaya  if host_machine.system() == 'windows'
79153c12917Smaya    if _shader_cache == 'true'
79253c12917Smaya      error('Shader Cache does not currently work on Windows')
79353c12917Smaya    endif
79453c12917Smaya  else
79553c12917Smaya    pre_args += '-DENABLE_SHADER_CACHE'
79653c12917Smaya    with_shader_cache = true
79753c12917Smaya  endif
79853c12917Smayaendif
79953c12917Smayaif with_amd_vk and not with_shader_cache
80001e04c3fSmrg  error('Radv requires shader cache support')
80101e04c3fSmrgendif
80201e04c3fSmrg
80301e04c3fSmrg# Check for GCC style builtins
80401e04c3fSmrgforeach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
80501e04c3fSmrg             'ffsll', 'popcount', 'popcountll', 'unreachable']
80601e04c3fSmrg  if cc.has_function(b)
80701e04c3fSmrg    pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
80801e04c3fSmrg  endif
80901e04c3fSmrgendforeach
81001e04c3fSmrg
81101e04c3fSmrg# check for GCC __attribute__
81201e04c3fSmrgforeach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
81301e04c3fSmrg             'warn_unused_result', 'weak',]
81401e04c3fSmrg  if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
81501e04c3fSmrg                 name : '__attribute__((@0@))'.format(a))
81601e04c3fSmrg    pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
81701e04c3fSmrg  endif
81801e04c3fSmrgendforeach
81901e04c3fSmrgif cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
82001e04c3fSmrg               name : '__attribute__((format(...)))')
82101e04c3fSmrg  pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
82201e04c3fSmrgendif
82301e04c3fSmrgif cc.compiles('struct __attribute__((packed)) foo { int bar; };',
82401e04c3fSmrg               name : '__attribute__((packed))')
82501e04c3fSmrg  pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
82601e04c3fSmrgendif
82701e04c3fSmrgif cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
82801e04c3fSmrg               name : '__attribute__((returns_nonnull))')
82901e04c3fSmrg  pre_args += '-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL'
83001e04c3fSmrgendif
83101e04c3fSmrgif cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
83201e04c3fSmrg                  int foo_hid(void) __attribute__((visibility("hidden")));
83301e04c3fSmrg                  int foo_int(void) __attribute__((visibility("internal")));
83401e04c3fSmrg                  int foo_pro(void) __attribute__((visibility("protected")));''',
83501e04c3fSmrg               name : '__attribute__((visibility(...)))')
83601e04c3fSmrg  pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
83701e04c3fSmrgendif
83801e04c3fSmrgif cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
83901e04c3fSmrg               name : '__attribute__((alias(...)))')
84001e04c3fSmrg  pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
84101e04c3fSmrgendif
84201e04c3fSmrgif cc.compiles('int foo(void) __attribute__((__noreturn__));',
84301e04c3fSmrg               name : '__attribute__((__noreturn__))')
84401e04c3fSmrg  pre_args += '-DHAVE_FUNC_ATTRIBUTE_NORETURN'
84501e04c3fSmrgendif
84601e04c3fSmrg
84701e04c3fSmrg# TODO: this is very incomplete
84853c12917Smayaif ['linux', 'cygwin', 'gnu', 'gnu/kfreebsd'].contains(host_machine.system())
84901e04c3fSmrg  pre_args += '-D_GNU_SOURCE'
85001e04c3fSmrgendif
85101e04c3fSmrg
85201e04c3fSmrg# Check for generic C arguments
85301e04c3fSmrgc_args = []
85401e04c3fSmrgforeach a : ['-Werror=implicit-function-declaration',
85501e04c3fSmrg             '-Werror=missing-prototypes', '-Werror=return-type',
85653c12917Smaya             '-Werror=incompatible-pointer-types',
85701e04c3fSmrg             '-fno-math-errno',
85801e04c3fSmrg             '-fno-trapping-math', '-Qunused-arguments']
85901e04c3fSmrg  if cc.has_argument(a)
86001e04c3fSmrg    c_args += a
86101e04c3fSmrg  endif
86201e04c3fSmrgendforeach
86301e04c3fSmrg
86401e04c3fSmrgforeach a : ['missing-field-initializers', 'format-truncation']
86501e04c3fSmrg  if cc.has_argument('-W' + a)
86601e04c3fSmrg    c_args += '-Wno-' + a
86701e04c3fSmrg  endif
86801e04c3fSmrgendforeach
86901e04c3fSmrg
87001e04c3fSmrgc_vis_args = []
87101e04c3fSmrgif cc.has_argument('-fvisibility=hidden')
87201e04c3fSmrg  c_vis_args += '-fvisibility=hidden'
87301e04c3fSmrgendif
87401e04c3fSmrg
87501e04c3fSmrg# Check for generic C++ arguments
87601e04c3fSmrgcpp_args = []
87701e04c3fSmrgforeach a : ['-Werror=return-type',
87801e04c3fSmrg             '-fno-math-errno', '-fno-trapping-math',
87901e04c3fSmrg             '-Qunused-arguments']
88001e04c3fSmrg  if cpp.has_argument(a)
88101e04c3fSmrg    cpp_args += a
88201e04c3fSmrg  endif
88301e04c3fSmrgendforeach
88401e04c3fSmrg
88501e04c3fSmrg# For some reason, the test for -Wno-foo always succeeds with gcc, even if the
88601e04c3fSmrg# option is not supported. Hence, check for -Wfoo instead.
88701e04c3fSmrg
88801e04c3fSmrgforeach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation']
88901e04c3fSmrg  if cpp.has_argument('-W' + a)
89001e04c3fSmrg    cpp_args += '-Wno-' + a
89101e04c3fSmrg  endif
89201e04c3fSmrgendforeach
89301e04c3fSmrg
89401e04c3fSmrgno_override_init_args = []
89501e04c3fSmrgforeach a : ['override-init', 'initializer-overrides']
89601e04c3fSmrg  if cc.has_argument('-W' + a)
89701e04c3fSmrg    no_override_init_args += '-Wno-' + a
89801e04c3fSmrg  endif
89901e04c3fSmrgendforeach
90001e04c3fSmrg
90101e04c3fSmrgcpp_vis_args = []
90201e04c3fSmrgif cpp.has_argument('-fvisibility=hidden')
90301e04c3fSmrg  cpp_vis_args += '-fvisibility=hidden'
90401e04c3fSmrgendif
90501e04c3fSmrg
90601e04c3fSmrg# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
90701e04c3fSmrg# in parts of the mesa code base that need to compile with old versions of
90801e04c3fSmrg# MSVC, mainly common code
90901e04c3fSmrgc_msvc_compat_args = []
91001e04c3fSmrgcpp_msvc_compat_args = []
91101e04c3fSmrgforeach a : ['-Werror=pointer-arith', '-Werror=vla']
91201e04c3fSmrg  if cc.has_argument(a)
91301e04c3fSmrg    c_msvc_compat_args += a
91401e04c3fSmrg  endif
91501e04c3fSmrg  if cpp.has_argument(a)
91601e04c3fSmrg    cpp_msvc_compat_args += a
91701e04c3fSmrg  endif
91801e04c3fSmrgendforeach
91901e04c3fSmrg
92001e04c3fSmrgif host_machine.cpu_family().startswith('x86')
92101e04c3fSmrg  pre_args += '-DUSE_SSE41'
92201e04c3fSmrg  with_sse41 = true
92301e04c3fSmrg  sse41_args = ['-msse4.1']
92401e04c3fSmrg
92501e04c3fSmrg  # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
92601e04c3fSmrg  # that's not guaranteed
92701e04c3fSmrg  if host_machine.cpu_family() == 'x86'
92801e04c3fSmrg    sse41_args += '-mstackrealign'
92901e04c3fSmrg  endif
93001e04c3fSmrgelse
93101e04c3fSmrg  with_sse41 = false
93201e04c3fSmrg  sse41_args = []
93301e04c3fSmrgendif
93401e04c3fSmrg
93501e04c3fSmrg# Check for GCC style atomics
93601e04c3fSmrgdep_atomic = null_dep
93701e04c3fSmrg
93801e04c3fSmrgif cc.compiles('''#include <stdint.h>
93901e04c3fSmrg                  int main() {
94001e04c3fSmrg                    struct {
94101e04c3fSmrg                      uint64_t *v;
94201e04c3fSmrg                    } x;
94301e04c3fSmrg                    return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
94401e04c3fSmrg                           (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
94501e04c3fSmrg
94601e04c3fSmrg                  }''',
94701e04c3fSmrg               name : 'GCC atomic builtins')
94801e04c3fSmrg  pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
94901e04c3fSmrg
95001e04c3fSmrg  # Not all atomic calls can be turned into lock-free instructions, in which
95101e04c3fSmrg  # GCC will make calls into the libatomic library. Check whether we need to
95201e04c3fSmrg  # link with -latomic.
95301e04c3fSmrg  #
95401e04c3fSmrg  # This can happen for 64-bit atomic operations on 32-bit architectures such
95501e04c3fSmrg  # as ARM.
95601e04c3fSmrg  if not cc.links('''#include <stdint.h>
95701e04c3fSmrg                     int main() {
95801e04c3fSmrg                       struct {
95901e04c3fSmrg                         uint64_t *v;
96001e04c3fSmrg                       } x;
96101e04c3fSmrg                       return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
96201e04c3fSmrg                              (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
96301e04c3fSmrg                     }''',
96401e04c3fSmrg                  name : 'GCC atomic builtins required -latomic')
96501e04c3fSmrg    dep_atomic = cc.find_library('atomic')
96601e04c3fSmrg  endif
96701e04c3fSmrgendif
96801e04c3fSmrgif not cc.links('''#include <stdint.h>
96901e04c3fSmrg                   uint64_t v;
97001e04c3fSmrg                   int main() {
97101e04c3fSmrg                     return __sync_add_and_fetch(&v, (uint64_t)1);
97201e04c3fSmrg                   }''',
97301e04c3fSmrg                dependencies : dep_atomic,
97401e04c3fSmrg                name : 'GCC 64bit atomics')
97501e04c3fSmrg  pre_args += '-DMISSING_64BIT_ATOMICS'
97601e04c3fSmrgendif
97701e04c3fSmrg
97801e04c3fSmrg# TODO: shared/static? Is this even worth doing?
97901e04c3fSmrg
98001e04c3fSmrg# When cross compiling we generally need to turn off the use of assembly,
98101e04c3fSmrg# because mesa's assembly relies on building an executable for the host system,
98201e04c3fSmrg# and running it to get information about struct sizes. There is at least one
98301e04c3fSmrg# case of cross compiling where we can use asm, and that's x86_64 -> x86 when
98401e04c3fSmrg# host OS == build OS, since in that case the build machine can run the host's
98501e04c3fSmrg# binaries.
98653c12917Smayaif with_asm and meson.is_cross_build()
98701e04c3fSmrg  if build_machine.system() != host_machine.system()
98801e04c3fSmrg    # TODO: It may be possible to do this with an exe_wrapper (like wine).
98901e04c3fSmrg    message('Cross compiling from one OS to another, disabling assembly.')
99001e04c3fSmrg    with_asm = false
99101e04c3fSmrg  elif not (build_machine.cpu_family().startswith('x86') and host_machine.cpu_family() == 'x86')
99201e04c3fSmrg    # FIXME: Gentoo always sets -m32 for x86_64 -> x86 builds, resulting in an
99301e04c3fSmrg    # x86 -> x86 cross compile. We use startswith rather than == to handle this
99401e04c3fSmrg    # case.
99501e04c3fSmrg    # TODO: There may be other cases where the 64 bit version of the
99601e04c3fSmrg    # architecture can run 32 bit binaries (aarch64 and armv7 for example)
99701e04c3fSmrg    message('''
99801e04c3fSmrg      Cross compiling to different architectures, and the host cannot run
99901e04c3fSmrg      the build machine's binaries. Disabling assembly.
100001e04c3fSmrg    ''')
100101e04c3fSmrg    with_asm = false
100201e04c3fSmrg  endif
100301e04c3fSmrgendif
100401e04c3fSmrg
100501e04c3fSmrgwith_asm_arch = ''
100601e04c3fSmrgif with_asm
100701e04c3fSmrg  if host_machine.cpu_family() == 'x86'
100801e04c3fSmrg    if system_has_kms_drm or host_machine.system() == 'gnu'
100901e04c3fSmrg      with_asm_arch = 'x86'
101001e04c3fSmrg      pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
101101e04c3fSmrg                   '-DUSE_SSE_ASM']
101201e04c3fSmrg
101301e04c3fSmrg      if with_glx_read_only_text
101401e04c3fSmrg         pre_args += ['-DGLX_X86_READONLY_TEXT']
101501e04c3fSmrg      endif
101601e04c3fSmrg    endif
101701e04c3fSmrg  elif host_machine.cpu_family() == 'x86_64'
101801e04c3fSmrg    if system_has_kms_drm
101901e04c3fSmrg      with_asm_arch = 'x86_64'
102001e04c3fSmrg      pre_args += ['-DUSE_X86_64_ASM']
102101e04c3fSmrg    endif
102201e04c3fSmrg  elif host_machine.cpu_family() == 'arm'
102301e04c3fSmrg    if system_has_kms_drm
102401e04c3fSmrg      with_asm_arch = 'arm'
102501e04c3fSmrg      pre_args += ['-DUSE_ARM_ASM']
102601e04c3fSmrg    endif
102701e04c3fSmrg  elif host_machine.cpu_family() == 'aarch64'
102801e04c3fSmrg    if system_has_kms_drm
102901e04c3fSmrg      with_asm_arch = 'aarch64'
103001e04c3fSmrg      pre_args += ['-DUSE_AARCH64_ASM']
103101e04c3fSmrg    endif
103201e04c3fSmrg  elif host_machine.cpu_family() == 'sparc64'
103301e04c3fSmrg    if system_has_kms_drm
103401e04c3fSmrg      with_asm_arch = 'sparc'
103501e04c3fSmrg      pre_args += ['-DUSE_SPARC_ASM']
103601e04c3fSmrg    endif
103701e04c3fSmrg  elif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
103801e04c3fSmrg    if system_has_kms_drm
103901e04c3fSmrg      with_asm_arch = 'ppc64le'
104001e04c3fSmrg      pre_args += ['-DUSE_PPC64LE_ASM']
104101e04c3fSmrg    endif
104201e04c3fSmrg  endif
104301e04c3fSmrgendif
104401e04c3fSmrg
104501e04c3fSmrg# Check for standard headers and functions
104601e04c3fSmrgif cc.has_header_symbol('sys/sysmacros.h', 'major')
104701e04c3fSmrg  pre_args += '-DMAJOR_IN_SYSMACROS'
104801e04c3fSmrgelif cc.has_header_symbol('sys/mkdev.h', 'major')
104901e04c3fSmrg  pre_args += '-DMAJOR_IN_MKDEV'
105001e04c3fSmrgendif
105101e04c3fSmrg
105253c12917Smayaforeach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h']
105301e04c3fSmrg  if cc.compiles('#include <@0@>'.format(h), name : '@0@'.format(h))
105401e04c3fSmrg    pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
105501e04c3fSmrg  endif
105601e04c3fSmrgendforeach
105701e04c3fSmrg
105801e04c3fSmrgforeach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create']
105901e04c3fSmrg  if cc.has_function(f)
106001e04c3fSmrg    pre_args += '-DHAVE_@0@'.format(f.to_upper())
106101e04c3fSmrg  endif
106201e04c3fSmrgendforeach
106301e04c3fSmrg
106453c12917Smayaif cc.has_header_symbol('errno.h', 'program_invocation_name',
106553c12917Smaya                        args : '-D_GNU_SOURCE')
106653c12917Smaya   pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'
106753c12917Smayaelif with_tools.contains('intel')
106853c12917Smaya  error('Intel tools require the program_invocation_name variable')
106953c12917Smayaendif
107053c12917Smaya
107101e04c3fSmrg# strtod locale support
107201e04c3fSmrgif cc.links('''
107301e04c3fSmrg    #define _GNU_SOURCE
107401e04c3fSmrg    #include <stdlib.h>
107501e04c3fSmrg    #include <locale.h>
107601e04c3fSmrg    #ifdef HAVE_XLOCALE_H
107701e04c3fSmrg    #include <xlocale.h>
107801e04c3fSmrg    #endif
107901e04c3fSmrg    int main() {
108001e04c3fSmrg      locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
108101e04c3fSmrg      const char *s = "1.0";
108201e04c3fSmrg      char *end;
108301e04c3fSmrg      double d = strtod_l(s, end, loc);
108401e04c3fSmrg      float f = strtof_l(s, end, loc);
108501e04c3fSmrg      freelocale(loc);
108601e04c3fSmrg      return 0;
108701e04c3fSmrg    }''',
108801e04c3fSmrg    args : pre_args,
108901e04c3fSmrg    name : 'strtod has locale support')
109001e04c3fSmrg  pre_args += '-DHAVE_STRTOD_L'
109101e04c3fSmrgendif
109201e04c3fSmrg
109301e04c3fSmrg# Check for some linker flags
109401e04c3fSmrgld_args_bsymbolic = []
109501e04c3fSmrgif cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
109601e04c3fSmrg  ld_args_bsymbolic += '-Wl,-Bsymbolic'
109701e04c3fSmrgendif
109801e04c3fSmrgld_args_gc_sections = []
109901e04c3fSmrgif cc.links('static char unused() { return 5; } int main() { return 0; }',
110001e04c3fSmrg            args : '-Wl,--gc-sections', name : 'gc-sections')
110101e04c3fSmrg  ld_args_gc_sections += '-Wl,--gc-sections'
110201e04c3fSmrgendif
110301e04c3fSmrgwith_ld_version_script = false
110401e04c3fSmrgif cc.links('int main() { return 0; }',
110501e04c3fSmrg            args : '-Wl,--version-script=@0@'.format(
110601e04c3fSmrg              join_paths(meson.source_root(), 'build-support/conftest.map')),
110701e04c3fSmrg            name : 'version-script')
110801e04c3fSmrg  with_ld_version_script = true
110901e04c3fSmrgendif
111001e04c3fSmrgwith_ld_dynamic_list = false
111101e04c3fSmrgif cc.links('int main() { return 0; }',
111201e04c3fSmrg            args : '-Wl,--dynamic-list=@0@'.format(
111301e04c3fSmrg              join_paths(meson.source_root(), 'build-support/conftest.dyn')),
111401e04c3fSmrg            name : 'dynamic-list')
111501e04c3fSmrg  with_ld_dynamic_list = true
111601e04c3fSmrgendif
111701e04c3fSmrgld_args_build_id = []
111801e04c3fSmrgif build_machine.system() != 'darwin'
111901e04c3fSmrg   ld_args_build_id += '-Wl,--build-id=sha1'
112001e04c3fSmrgendif
112101e04c3fSmrg
112201e04c3fSmrg# check for dl support
112301e04c3fSmrgif cc.has_function('dlopen')
112401e04c3fSmrg  dep_dl = null_dep
112501e04c3fSmrgelse
112601e04c3fSmrg  dep_dl = cc.find_library('dl')
112701e04c3fSmrgendif
112801e04c3fSmrgif cc.has_function('dladdr', dependencies : dep_dl)
112901e04c3fSmrg  # This is really only required for megadrivers
113001e04c3fSmrg  pre_args += '-DHAVE_DLADDR'
113101e04c3fSmrgendif
113201e04c3fSmrg
113301e04c3fSmrgif cc.has_function('dl_iterate_phdr')
113401e04c3fSmrg  pre_args += '-DHAVE_DL_ITERATE_PHDR'
113501e04c3fSmrgelif with_intel_vk
113601e04c3fSmrg  error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
113753c12917Smayaelif with_dri_i965 and with_shader_cache
113801e04c3fSmrg  error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
113901e04c3fSmrgendif
114001e04c3fSmrg
114101e04c3fSmrg# Determine whether or not the rt library is needed for time functions
114201e04c3fSmrgif cc.has_function('clock_gettime')
114301e04c3fSmrg  dep_clock = null_dep
114401e04c3fSmrgelse
114501e04c3fSmrg  dep_clock = cc.find_library('rt')
114601e04c3fSmrgendif
114701e04c3fSmrg
114801e04c3fSmrg# TODO: some of these may be conditional
114901e04c3fSmrgdep_zlib = dependency('zlib', version : '>= 1.2.3')
115001e04c3fSmrgpre_args += '-DHAVE_ZLIB'
115101e04c3fSmrgdep_thread = dependency('threads')
115201e04c3fSmrgif dep_thread.found() and host_machine.system() != 'windows'
115301e04c3fSmrg  pre_args += '-DHAVE_PTHREAD'
115401e04c3fSmrg  if cc.has_function(
115501e04c3fSmrg      'pthread_setaffinity_np',
115601e04c3fSmrg      dependencies : dep_thread,
115701e04c3fSmrg      prefix : '#include <pthread.h>',
115801e04c3fSmrg      args : '-D_GNU_SOURCE')
115901e04c3fSmrg    pre_args += '-DHAVE_PTHREAD_SETAFFINITY'
116001e04c3fSmrg  endif
116101e04c3fSmrgendif
116201e04c3fSmrgdep_expat = dependency('expat')
116301e04c3fSmrg# this only exists on linux so either this is linux and it will be found, or
116401e04c3fSmrg# its not linux and and wont
116501e04c3fSmrgdep_m = cc.find_library('m', required : false)
116601e04c3fSmrg
116701e04c3fSmrg# Check for libdrm. various drivers have different libdrm version requirements,
116801e04c3fSmrg# but we always want to use the same version for all libdrm modules. That means
116901e04c3fSmrg# even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and
117001e04c3fSmrg# bar are both on use 2.4.3 for both of them
117101e04c3fSmrgdep_libdrm_amdgpu = null_dep
117201e04c3fSmrgdep_libdrm_radeon = null_dep
117301e04c3fSmrgdep_libdrm_nouveau = null_dep
117401e04c3fSmrgdep_libdrm_etnaviv = null_dep
117501e04c3fSmrgdep_libdrm_intel = null_dep
117601e04c3fSmrg
117753c12917Smaya_drm_amdgpu_ver = '2.4.97'
117801e04c3fSmrg_drm_radeon_ver = '2.4.71'
117901e04c3fSmrg_drm_nouveau_ver = '2.4.66'
118001e04c3fSmrg_drm_etnaviv_ver = '2.4.89'
118101e04c3fSmrg_drm_intel_ver = '2.4.75'
118253c12917Smaya_drm_ver = '2.4.81'
118301e04c3fSmrg
118401e04c3fSmrg_libdrm_checks = [
118501e04c3fSmrg  ['intel', with_dri_i915 or with_gallium_i915],
118601e04c3fSmrg  ['amdgpu', with_amd_vk or with_gallium_radeonsi],
118701e04c3fSmrg  ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
118801e04c3fSmrg              with_gallium_r300 or with_gallium_r600)],
118901e04c3fSmrg  ['nouveau', (with_gallium_nouveau or with_dri_nouveau)],
119001e04c3fSmrg  ['etnaviv', with_gallium_etnaviv],
119101e04c3fSmrg]
119201e04c3fSmrg
119301e04c3fSmrg# VC4 only needs core libdrm support of this version, not a libdrm_vc4
119401e04c3fSmrg# library.
119501e04c3fSmrgif with_gallium_vc4
119601e04c3fSmrg  _drm_ver = '2.4.89'
119701e04c3fSmrgendif
119801e04c3fSmrg
119901e04c3fSmrg# Loop over the enables versions and get the highest libdrm requirement for all
120001e04c3fSmrg# active drivers.
120101e04c3fSmrg_drm_blame = ''
120201e04c3fSmrgforeach d : _libdrm_checks
120301e04c3fSmrg  ver = get_variable('_drm_@0@_ver'.format(d[0]))
120401e04c3fSmrg  if d[1] and ver.version_compare('>' + _drm_ver)
120501e04c3fSmrg    _drm_ver = ver
120601e04c3fSmrg    _drm_blame = d[0]
120701e04c3fSmrg  endif
120801e04c3fSmrgendforeach
120901e04c3fSmrgif _drm_blame != ''
121001e04c3fSmrg  message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame))
121101e04c3fSmrgendif
121201e04c3fSmrg
121301e04c3fSmrg# Then get each libdrm module
121401e04c3fSmrgforeach d : _libdrm_checks
121501e04c3fSmrg  if d[1]
121601e04c3fSmrg    set_variable(
121701e04c3fSmrg      'dep_libdrm_' + d[0],
121801e04c3fSmrg      dependency('libdrm_' + d[0], version : '>=' + _drm_ver)
121901e04c3fSmrg    )
122001e04c3fSmrg  endif
122101e04c3fSmrgendforeach
122201e04c3fSmrg
122301e04c3fSmrgwith_gallium_drisw_kms = false
122401e04c3fSmrgdep_libdrm = dependency(
122501e04c3fSmrg  'libdrm', version : '>=' + _drm_ver,
122601e04c3fSmrg  required : with_dri2 or with_dri3
122701e04c3fSmrg)
122801e04c3fSmrgif dep_libdrm.found()
122901e04c3fSmrg  pre_args += '-DHAVE_LIBDRM'
123001e04c3fSmrg  if with_dri_platform == 'drm' and with_dri
123101e04c3fSmrg    with_gallium_drisw_kms = true
123201e04c3fSmrg  endif
123301e04c3fSmrgendif
123401e04c3fSmrg
123501e04c3fSmrgllvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
123601e04c3fSmrgllvm_optional_modules = []
123701e04c3fSmrgif with_amd_vk or with_gallium_radeonsi or with_gallium_r600
123801e04c3fSmrg  llvm_modules += ['amdgpu', 'native', 'bitreader', 'ipo']
123901e04c3fSmrg  if with_gallium_r600
124001e04c3fSmrg    llvm_modules += 'asmparser'
124101e04c3fSmrg  endif
124201e04c3fSmrgendif
124301e04c3fSmrgif with_gallium_opencl
124401e04c3fSmrg  llvm_modules += [
124501e04c3fSmrg    'all-targets', 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
124601e04c3fSmrg    'lto', 'option', 'objcarcopts', 'profiledata',
124701e04c3fSmrg  ]
124801e04c3fSmrg  llvm_optional_modules += ['coroutines']
124901e04c3fSmrgendif
125001e04c3fSmrg
125101e04c3fSmrgif with_amd_vk or with_gallium_radeonsi
125253c12917Smaya  _llvm_version = '>= 7.0.0'
125301e04c3fSmrgelif with_gallium_swr
125401e04c3fSmrg  _llvm_version = '>= 6.0.0'
125501e04c3fSmrgelif with_gallium_opencl or with_gallium_r600
125601e04c3fSmrg  _llvm_version = '>= 3.9.0'
125701e04c3fSmrgelse
125801e04c3fSmrg  _llvm_version = '>= 3.3.0'
125901e04c3fSmrgendif
126001e04c3fSmrg
126101e04c3fSmrg_shared_llvm = get_option('shared-llvm')
126201e04c3fSmrg
126301e04c3fSmrg_llvm = get_option('llvm')
126401e04c3fSmrgdep_llvm = null_dep
126501e04c3fSmrgwith_llvm = false
126601e04c3fSmrgif _llvm != 'false'
126701e04c3fSmrg  dep_llvm = dependency(
126801e04c3fSmrg    'llvm',
126901e04c3fSmrg    version : _llvm_version,
127001e04c3fSmrg    modules : llvm_modules,
127101e04c3fSmrg    optional_modules : llvm_optional_modules,
127201e04c3fSmrg    required : (
127301e04c3fSmrg      with_amd_vk or with_gallium_radeonsi or with_gallium_swr or
127401e04c3fSmrg      with_gallium_opencl or _llvm == 'true'
127501e04c3fSmrg    ),
127601e04c3fSmrg    static : not _shared_llvm,
127753c12917Smaya    method : 'config-tool',
127801e04c3fSmrg  )
127901e04c3fSmrg  with_llvm = dep_llvm.found()
128001e04c3fSmrgendif
128101e04c3fSmrgif with_llvm
128201e04c3fSmrg  _llvm_version = dep_llvm.version().split('.')
128301e04c3fSmrg  pre_args += [
128401e04c3fSmrg    '-DHAVE_LLVM=0x0@0@0@1@'.format(_llvm_version[0], _llvm_version[1]),
128553c12917Smaya    '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version()),
128601e04c3fSmrg  ]
128701e04c3fSmrg
128801e04c3fSmrg  # LLVM can be built without rtti, turning off rtti changes the ABI of C++
128901e04c3fSmrg  # programs, so we need to build all C++ code in mesa without rtti as well to
129001e04c3fSmrg  # ensure that linking works.
129101e04c3fSmrg  if dep_llvm.get_configtool_variable('has-rtti') == 'NO'
129201e04c3fSmrg    if with_gallium_nouveau
129301e04c3fSmrg      error('The Nouveau driver requires rtti. You either need to turn off nouveau or use an LLVM built with LLVM_ENABLE_RTTI.')
129453c12917Smaya    elif with_gallium_opencl
129553c12917Smaya      error('The Clover OpenCL state tracker requires rtti, you need to turn off clover or use an LLVM built with LLVM_ENABLE_RTTI.')
129601e04c3fSmrg    endif
129701e04c3fSmrg    cpp_args += '-fno-rtti'
129801e04c3fSmrg  endif
129901e04c3fSmrgelif with_amd_vk or with_gallium_radeonsi or with_gallium_swr
130001e04c3fSmrg  error('The following drivers require LLVM: Radv, RadeonSI, SWR. One of these is enabled, but LLVM is disabled.')
130153c12917Smayaelif with_gallium_opencl
130253c12917Smaya  error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
130301e04c3fSmrgendif
130401e04c3fSmrg
130501e04c3fSmrgif (with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or
130601e04c3fSmrg    (with_gallium_r600 and with_llvm))
130701e04c3fSmrg  dep_elf = dependency('libelf', required : false)
130801e04c3fSmrg  if not dep_elf.found()
130901e04c3fSmrg    dep_elf = cc.find_library('elf')
131001e04c3fSmrg  endif
131101e04c3fSmrgelse
131201e04c3fSmrg  dep_elf = null_dep
131301e04c3fSmrgendif
131401e04c3fSmrg
131501e04c3fSmrgdep_glvnd = null_dep
131601e04c3fSmrgif with_glvnd
131701e04c3fSmrg  dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
131801e04c3fSmrg  pre_args += '-DUSE_LIBGLVND=1'
131901e04c3fSmrgendif
132001e04c3fSmrg
132101e04c3fSmrgif with_valgrind != 'false'
132201e04c3fSmrg  dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
132301e04c3fSmrg  if dep_valgrind.found()
132401e04c3fSmrg    pre_args += '-DHAVE_VALGRIND'
132501e04c3fSmrg  endif
132601e04c3fSmrgelse
132701e04c3fSmrg  dep_valgrind = null_dep
132801e04c3fSmrgendif
132901e04c3fSmrg
133001e04c3fSmrg# pthread stubs. Lets not and say we didn't
133101e04c3fSmrg
133201e04c3fSmrgprog_bison = find_program('bison', required : with_any_opengl)
133301e04c3fSmrgprog_flex = find_program('flex', required : with_any_opengl)
133401e04c3fSmrg
133501e04c3fSmrgdep_selinux = null_dep
133601e04c3fSmrgif get_option('selinux')
133701e04c3fSmrg  dep_selinux = dependency('libselinux')
133801e04c3fSmrg  pre_args += '-DMESA_SELINUX'
133901e04c3fSmrgendif
134001e04c3fSmrg
134101e04c3fSmrgif with_libunwind != 'false'
134201e04c3fSmrg  dep_unwind = dependency('libunwind', required : with_libunwind == 'true')
134301e04c3fSmrg  if dep_unwind.found()
134401e04c3fSmrg    pre_args += '-DHAVE_LIBUNWIND'
134501e04c3fSmrg  endif
134601e04c3fSmrgelse
134701e04c3fSmrg  dep_unwind = null_dep
134801e04c3fSmrgendif
134901e04c3fSmrg
135001e04c3fSmrgif with_osmesa != 'none'
135101e04c3fSmrg  if with_osmesa == 'classic' and not with_dri_swrast
135201e04c3fSmrg    error('OSMesa classic requires dri (classic) swrast.')
135301e04c3fSmrg  endif
135401e04c3fSmrg  if with_osmesa == 'gallium' and not with_gallium_softpipe
135501e04c3fSmrg    error('OSMesa gallium requires gallium softpipe or llvmpipe.')
135601e04c3fSmrg  endif
135701e04c3fSmrg  osmesa_lib_name = 'OSMesa'
135801e04c3fSmrg  osmesa_bits = get_option('osmesa-bits')
135901e04c3fSmrg  if osmesa_bits != '8'
136001e04c3fSmrg    if with_dri or with_glx != 'disabled'
136101e04c3fSmrg      error('OSMesa bits must be 8 if building glx or dir based drivers')
136201e04c3fSmrg    endif
136301e04c3fSmrg    osmesa_lib_name = osmesa_lib_name + osmesa_bits
136401e04c3fSmrg    pre_args += [
136501e04c3fSmrg      '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
136601e04c3fSmrg    ]
136701e04c3fSmrg  endif
136801e04c3fSmrgendif
136901e04c3fSmrg
137001e04c3fSmrg# TODO: symbol mangling
137101e04c3fSmrg
137201e04c3fSmrgif with_platform_wayland
137301e04c3fSmrg  dep_wl_scanner = dependency('wayland-scanner', native: true)
137401e04c3fSmrg  prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner'))
137501e04c3fSmrg  if dep_wl_scanner.version().version_compare('>= 1.15')
137601e04c3fSmrg    wl_scanner_arg = 'private-code'
137701e04c3fSmrg  else
137801e04c3fSmrg    wl_scanner_arg = 'code'
137901e04c3fSmrg  endif
138001e04c3fSmrg  dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
138101e04c3fSmrg  dep_wayland_client = dependency('wayland-client', version : '>=1.11')
138201e04c3fSmrg  dep_wayland_server = dependency('wayland-server', version : '>=1.11')
138301e04c3fSmrg  if with_egl
138401e04c3fSmrg    dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3')
138501e04c3fSmrg    dep_wayland_egl_headers = declare_dependency(
138601e04c3fSmrg      compile_args : run_command(prog_pkgconfig, ['wayland-egl-backend', '--cflags']).stdout().split())
138701e04c3fSmrg  endif
138801e04c3fSmrg  wayland_dmabuf_xml = join_paths(
138901e04c3fSmrg    dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
139001e04c3fSmrg    'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
139101e04c3fSmrg  )
139201e04c3fSmrg  pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
139301e04c3fSmrgendif
139401e04c3fSmrg
139501e04c3fSmrgdep_x11 = null_dep
139601e04c3fSmrgdep_xext = null_dep
139701e04c3fSmrgdep_xdamage = null_dep
139801e04c3fSmrgdep_xfixes = null_dep
139901e04c3fSmrgdep_x11_xcb = null_dep
140001e04c3fSmrgdep_xcb = null_dep
140101e04c3fSmrgdep_xcb_glx = null_dep
140201e04c3fSmrgdep_xcb_dri2 = null_dep
140301e04c3fSmrgdep_xcb_dri3 = null_dep
140401e04c3fSmrgdep_dri2proto = null_dep
140501e04c3fSmrgdep_glproto = null_dep
140601e04c3fSmrgdep_xxf86vm = null_dep
140701e04c3fSmrgdep_xcb_dri3 = null_dep
140801e04c3fSmrgdep_xcb_present = null_dep
140901e04c3fSmrgdep_xcb_sync = null_dep
141001e04c3fSmrgdep_xcb_xfixes = null_dep
141101e04c3fSmrgdep_xshmfence = null_dep
141201e04c3fSmrgdep_xcb_xrandr = null_dep
141301e04c3fSmrgdep_xlib_xrandr = null_dep
141401e04c3fSmrgif with_platform_x11
141501e04c3fSmrg  if with_glx == 'xlib' or with_glx == 'gallium-xlib'
141601e04c3fSmrg    dep_x11 = dependency('x11')
141701e04c3fSmrg    dep_xext = dependency('xext')
141801e04c3fSmrg    dep_xcb = dependency('xcb')
141901e04c3fSmrg  elif with_glx == 'dri'
142001e04c3fSmrg    dep_x11 = dependency('x11')
142101e04c3fSmrg    dep_xext = dependency('xext')
142201e04c3fSmrg    dep_xdamage = dependency('xdamage', version : '>= 1.1')
142301e04c3fSmrg    dep_xfixes = dependency('xfixes')
142401e04c3fSmrg    dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
142501e04c3fSmrg  endif
142653c12917Smaya  if (with_any_vk or with_glx == 'dri' or with_egl or
142701e04c3fSmrg       (with_gallium_vdpau or with_gallium_xvmc or with_gallium_va or
142801e04c3fSmrg        with_gallium_omx != 'disabled'))
142901e04c3fSmrg    dep_xcb = dependency('xcb')
143001e04c3fSmrg    dep_x11_xcb = dependency('x11-xcb')
143101e04c3fSmrg  endif
143201e04c3fSmrg  if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
143301e04c3fSmrg    dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
143401e04c3fSmrg
143501e04c3fSmrg    if with_dri3
143601e04c3fSmrg      pre_args += '-DHAVE_DRI3'
143701e04c3fSmrg      dep_xcb_dri3 = dependency('xcb-dri3')
143801e04c3fSmrg      dep_xcb_present = dependency('xcb-present')
143901e04c3fSmrg      # until xcb-dri3 has been around long enough to make a hard-dependency:
144001e04c3fSmrg      if (dep_xcb_dri3.version().version_compare('>= 1.13') and
144101e04c3fSmrg          dep_xcb_present.version().version_compare('>= 1.13'))
144201e04c3fSmrg        pre_args += '-DHAVE_DRI3_MODIFIERS'
144301e04c3fSmrg      endif
144401e04c3fSmrg      dep_xcb_sync = dependency('xcb-sync')
144501e04c3fSmrg      dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
144601e04c3fSmrg    endif
144701e04c3fSmrg  endif
144853c12917Smaya  if with_glx == 'dri' or with_glx == 'gallium-xlib'
144953c12917Smaya    dep_glproto = dependency('glproto', version : '>= 1.4.14')
145053c12917Smaya  endif
145153c12917Smaya  if with_glx == 'dri' 
145201e04c3fSmrg    if with_dri_platform == 'drm'
145301e04c3fSmrg      dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
145401e04c3fSmrg      dep_xxf86vm = dependency('xxf86vm')
145501e04c3fSmrg    endif
145601e04c3fSmrg  endif
145701e04c3fSmrg  if (with_egl or (
145801e04c3fSmrg      with_gallium_vdpau or with_gallium_xvmc or with_gallium_xa or
145901e04c3fSmrg      with_gallium_omx != 'disabled'))
146001e04c3fSmrg    dep_xcb_xfixes = dependency('xcb-xfixes')
146101e04c3fSmrg  endif
146201e04c3fSmrg  if with_xlib_lease
146301e04c3fSmrg    dep_xcb_xrandr = dependency('xcb-randr')
146401e04c3fSmrg    dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
146501e04c3fSmrg  endif
146601e04c3fSmrgendif
146701e04c3fSmrg
146801e04c3fSmrgif get_option('gallium-extra-hud')
146901e04c3fSmrg  pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
147001e04c3fSmrgendif
147101e04c3fSmrg
147201e04c3fSmrg_sensors = get_option('lmsensors')
147301e04c3fSmrgif _sensors != 'false'
147401e04c3fSmrg  dep_lmsensors = cc.find_library('sensors', required : _sensors == 'true')
147501e04c3fSmrg  if dep_lmsensors.found()
147601e04c3fSmrg    pre_args += '-DHAVE_LIBSENSORS=1'
147701e04c3fSmrg  endif
147801e04c3fSmrgelse
147901e04c3fSmrg  dep_lmsensors = null_dep
148001e04c3fSmrgendif
148101e04c3fSmrg
148201e04c3fSmrgforeach a : pre_args
148301e04c3fSmrg  add_project_arguments(a, language : ['c', 'cpp'])
148401e04c3fSmrgendforeach
148501e04c3fSmrgforeach a : c_args
148601e04c3fSmrg  add_project_arguments(a, language : ['c'])
148701e04c3fSmrgendforeach
148801e04c3fSmrgforeach a : cpp_args
148901e04c3fSmrg  add_project_arguments(a, language : ['cpp'])
149001e04c3fSmrgendforeach
149101e04c3fSmrg
149201e04c3fSmrggl_priv_reqs = []
149301e04c3fSmrg
149401e04c3fSmrgif with_glx == 'xlib' or with_glx == 'gallium-xlib'
149501e04c3fSmrg  gl_priv_reqs += ['x11', 'xext', 'xcb']
149601e04c3fSmrgelif with_glx == 'dri'
149701e04c3fSmrg  gl_priv_reqs += [
149801e04c3fSmrg    'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
149901e04c3fSmrg    'xcb-glx >= 1.8.1']
150001e04c3fSmrg  if with_dri_platform == 'drm'
150101e04c3fSmrg    gl_priv_reqs += 'xcb-dri2 >= 1.8'
150201e04c3fSmrg    gl_priv_reqs += 'xxf86vm'
150301e04c3fSmrg  endif
150401e04c3fSmrgendif
150501e04c3fSmrgif dep_libdrm.found()
150601e04c3fSmrg  gl_priv_reqs += 'libdrm >= 2.4.75'
150701e04c3fSmrgendif
150801e04c3fSmrg
150901e04c3fSmrggl_priv_libs = []
151001e04c3fSmrgif dep_thread.found()
151101e04c3fSmrg  gl_priv_libs += ['-lpthread', '-pthread']
151201e04c3fSmrgendif
151301e04c3fSmrgif dep_m.found()
151401e04c3fSmrg  gl_priv_libs += '-lm'
151501e04c3fSmrgendif
151601e04c3fSmrgif dep_dl.found()
151701e04c3fSmrg  gl_priv_libs += '-ldl'
151801e04c3fSmrgendif
151901e04c3fSmrg
152001e04c3fSmrgpkg = import('pkgconfig')
152101e04c3fSmrg
152253c12917Smayaprog_nm = find_program('nm', required : false)
152301e04c3fSmrgenv_test = environment()
152453c12917Smayaif prog_nm.found()
152553c12917Smaya  env_test.set('NM', prog_nm.path())
152653c12917Smayaendif
152753c12917Smaya
152853c12917Smaya# This quirk needs to be applied to sources with functions defined in assembly
152953c12917Smaya# as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391
153053c12917Smayagcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : []
153101e04c3fSmrg
153201e04c3fSmrgsubdir('include')
153301e04c3fSmrgsubdir('bin')
153401e04c3fSmrgsubdir('src')
153553c12917Smaya
153653c12917Smaya# Meson 0.49 and earlier seems to have a bug that fails to evaluate the string-
153753c12917Smaya# formatting below unless the first argument is passed as a variable. This has
153853c12917Smaya# been fixed in Meson 0.50 and beyond, but we need to keep it like this for now
153953c12917Smaya# for backwards compatibility.
154053c12917Smaya_with_opengl_string = with_opengl ? 'yes' : 'no'
154153c12917Smaya
154253c12917Smayalines = ['',
154353c12917Smaya  'prefix:          ' + get_option('prefix'),
154453c12917Smaya  'libdir:          ' + get_option('libdir'),
154553c12917Smaya  'includedir:      ' + get_option('includedir'),
154653c12917Smaya  '',
154753c12917Smaya  'OpenGL:          @0@ (ES1: @1@ ES2: @2@)'.format(_with_opengl_string,
154853c12917Smaya                                                    with_gles1 ? 'yes' : 'no',
154953c12917Smaya                                                    with_gles2 ? 'yes' : 'no'),
155053c12917Smaya]
155153c12917Smaya
155253c12917Smayalines += ''
155353c12917Smayaif with_osmesa != 'none'
155453c12917Smaya  suffix = ''
155553c12917Smaya  if with_osmesa == 'gallium'
155653c12917Smaya    suffix = '(Gallium)'
155753c12917Smaya  endif
155853c12917Smaya  lines += 'OSMesa:          lib' + osmesa_lib_name + suffix
155953c12917Smayaelse
156053c12917Smaya  lines += 'OSMesa:          no'
156153c12917Smayaendif
156253c12917Smaya
156353c12917Smayalines += ''
156453c12917Smayaif with_dri
156553c12917Smaya  lines += 'DRI platform:    ' + with_dri_platform
156653c12917Smaya  if dri_drivers.length() != 0 and dri_drivers != ['']
156753c12917Smaya    lines += 'DRI drivers:     ' + ' '.join(dri_drivers)
156853c12917Smaya  else
156953c12917Smaya    lines += 'DRI drivers:     no'
157053c12917Smaya  endif
157153c12917Smaya  lines += 'DRI driver dir:  ' + dri_drivers_path
157253c12917Smayaendif
157353c12917Smaya
157453c12917Smayalines += ''
157553c12917Smayaif with_glx != 'disabled'
157653c12917Smaya  if with_glx == 'dri'
157753c12917Smaya    lines += 'GLX:             DRI-based'
157853c12917Smaya  elif with_glx == 'xlib'
157953c12917Smaya    lines += 'GLX:             Xlib-based'
158053c12917Smaya  elif with_glx == 'gallium-xlib'
158153c12917Smaya    lines += 'GLX:             Xlib-based (Gallium)'
158253c12917Smaya  else
158353c12917Smaya    lines += 'GLX:             ' + with_glx
158453c12917Smaya  endif
158553c12917Smayaendif
158653c12917Smaya
158753c12917Smayalines += ''
158853c12917Smayalines += 'EGL:             ' + (with_egl ? 'yes' : 'no')
158953c12917Smayaif with_egl
159053c12917Smaya  egl_drivers = []
159153c12917Smaya  if with_dri
159253c12917Smaya    egl_drivers += 'builtin:egl_dri2'
159353c12917Smaya  endif
159453c12917Smaya  if with_dri3
159553c12917Smaya    egl_drivers += 'builtin:egl_dri3'
159653c12917Smaya  endif
159753c12917Smaya  lines += 'EGL drivers:     ' + ' '.join(egl_drivers)
159853c12917Smayaendif
159953c12917Smayalines += 'GBM:             ' + (with_gbm ? 'yes' : 'no')
160053c12917Smayaif with_platforms
160153c12917Smaya  lines += 'EGL/Vulkan/VL platforms:   ' + ' '.join(_platforms)
160253c12917Smayaendif
160353c12917Smaya
160453c12917Smayalines += ''
160553c12917Smayaif with_any_vk
160653c12917Smaya  lines += 'Vulkan drivers:  ' + ' '.join(_vulkan_drivers)
160753c12917Smaya  lines += 'Vulkan ICD dir:  ' + with_vulkan_icd_dir
160853c12917Smayaelse
160953c12917Smaya  lines += 'Vulkan drivers:  no'
161053c12917Smayaendif
161153c12917Smaya
161253c12917Smayalines += ''
161353c12917Smayaif with_llvm
161453c12917Smaya  lines += 'llvm:            yes'
161553c12917Smaya  lines += 'llvm-version:    ' + dep_llvm.version()
161653c12917Smayaelse
161753c12917Smaya  lines += 'llvm:            no'
161853c12917Smayaendif
161953c12917Smaya
162053c12917Smayalines += ''
162153c12917Smayaif with_gallium
162253c12917Smaya  lines += 'Gallium drivers: ' + ' '.join(gallium_drivers)
162353c12917Smaya  gallium_st = ['mesa']
162453c12917Smaya  if with_gallium_xa
162553c12917Smaya    gallium_st += 'xa'
162653c12917Smaya  endif
162753c12917Smaya  if with_gallium_xvmc
162853c12917Smaya    gallium_st += 'xvmc'
162953c12917Smaya  endif
163053c12917Smaya  if with_gallium_xvmc
163153c12917Smaya    gallium_st += 'xvmc'
163253c12917Smaya  endif
163353c12917Smaya  if with_gallium_vdpau
163453c12917Smaya    gallium_st += 'vdpau'
163553c12917Smaya  endif
163653c12917Smaya  if with_gallium_omx != 'disabled'
163753c12917Smaya    gallium_st += 'omx' + with_gallium_omx
163853c12917Smaya  endif
163953c12917Smaya  if with_gallium_va
164053c12917Smaya    gallium_st += 'va'
164153c12917Smaya  endif
164253c12917Smaya  if with_gallium_st_nine
164353c12917Smaya    gallium_st += 'nine'
164453c12917Smaya  endif
164553c12917Smaya  if with_gallium_opencl
164653c12917Smaya    gallium_st += 'clover'
164753c12917Smaya  endif
164853c12917Smaya  lines += 'Gallium st:      ' + ' '.join(gallium_st)
164953c12917Smayaelse
165053c12917Smaya  lines += 'Gallium:         no'
165153c12917Smayaendif
165253c12917Smaya
165353c12917Smayalines += 'HUD lmsensors:   ' + (dep_lmsensors.found() ? 'yes' : 'no')
165453c12917Smaya
165553c12917Smayalines += ''
165653c12917Smayalines += 'Shared-glapi:    ' + (with_shared_glapi ? 'yes' : 'no')
165753c12917Smaya
165853c12917Smaya
165953c12917Smayaindent = '        '
166053c12917Smayasummary = indent + ('\n' + indent).join(lines)
166153c12917Smayamessage('Configuration summary:\n@0@\n'.format(summary))
1662