1 # Copyright © 2017-2020 Intel Corporation
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 version : files('VERSION'),
26 meson_version : '>= 0.60',
27 default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++17', 'rust_std=2021']
30 cc = meson.get_compiler('c')
31 cpp = meson.get_compiler('cpp')
33 null_dep = dependency('', required : false)
35 if get_option('layout') != 'mirror'
36 error('`mirror` is the only build directory layout supported')
39 # Arguments for the preprocessor, put these in a separate array from the C and
40 # C++ (cpp in meson terminology) arguments since they need to be added to the
41 # default arguments for both C and C++.
43 '-D__STDC_CONSTANT_MACROS',
44 '-D__STDC_FORMAT_MACROS',
45 '-D__STDC_LIMIT_MACROS',
46 '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
47 '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/-/issues"',
49 # Arguments for c or cpp compiler, can be compiler options
55 with_moltenvk_dir = get_option('moltenvk-dir')
56 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
57 with_tests = get_option('build-tests')
58 with_glcpp_tests = get_option('enable-glcpp-tests')
59 with_aco_tests = get_option('build-aco-tests')
60 with_glx_read_only_text = get_option('glx-read-only-text')
61 with_glx_direct = get_option('glx-direct')
62 with_osmesa = get_option('osmesa')
63 with_vulkan_overlay_layer = get_option('vulkan-layers').contains('overlay')
64 with_vulkan_device_select_layer = get_option('vulkan-layers').contains('device-select')
65 with_tools = get_option('tools')
66 if with_tools.contains('all')
83 with_any_vulkan_layers = get_option('vulkan-layers').length() != 0
84 with_intel_tools = with_tools.contains('intel') or with_tools.contains('intel-ui')
85 with_imgui = with_intel_tools or with_vulkan_overlay_layer
87 dri_drivers_path = get_option('dri-drivers-path')
88 if dri_drivers_path == ''
89 dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
91 dri_search_path = get_option('dri-search-path')
92 if dri_search_path == ''
93 dri_search_path = dri_drivers_path
96 gbm_backends_path = get_option('gbm-backends-path')
97 if gbm_backends_path == ''
98 gbm_backends_path = join_paths(get_option('prefix'), get_option('libdir'), 'gbm')
101 # Default shared glapi off for windows, on elsewhere.
102 with_shared_glapi = get_option('shared-glapi') \
103 .disable_auto_if(host_machine.system() == 'windows') \
106 with_opengl = get_option('opengl')
108 with_gles1 = get_option('gles1') \
109 .require(with_shared_glapi, error_message : 'OpengGL ES 1.x requires shared-glapi') \
112 with_gles2 = get_option('gles2') \
113 .require(with_shared_glapi, error_message : 'OpengGL ES 2.x requires shared-glapi') \
116 pre_args += '-DHAVE_OPENGL=@0@'.format(with_opengl ? '1' : '0')
117 pre_args += '-DHAVE_OPENGL_ES_1=@0@'.format(with_gles1 ? '1' : '0')
118 pre_args += '-DHAVE_OPENGL_ES_2=@0@'.format(with_gles2 ? '1' : '0')
120 with_any_opengl = with_opengl or with_gles1 or with_gles2
121 # Only build shared_glapi if at least one OpenGL API is enabled
122 with_shared_glapi = with_shared_glapi and with_any_opengl
124 system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'android'].contains(host_machine.system())
126 gallium_drivers = get_option('gallium-drivers')
127 if gallium_drivers.contains('auto')
128 if system_has_kms_drm
130 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
132 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast',
133 'iris', 'crocus', 'i915'
135 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
137 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau', 'svga',
138 'tegra', 'virgl', 'lima', 'panfrost', 'swrast'
140 elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
142 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'swrast'
144 elif ['loongarch64'].contains(host_machine.cpu_family())
146 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'etnaviv', 'swrast'
149 error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
150 host_machine.cpu_family()))
152 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
153 gallium_drivers = ['swrast']
155 error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
156 host_machine.system()))
159 with_gallium_radeonsi = gallium_drivers.contains('radeonsi')
160 with_gallium_r300 = gallium_drivers.contains('r300')
161 with_gallium_r600 = gallium_drivers.contains('r600')
162 with_gallium_nouveau = gallium_drivers.contains('nouveau')
163 with_gallium_freedreno = gallium_drivers.contains('freedreno')
164 with_gallium_softpipe = gallium_drivers.contains('swrast')
165 with_gallium_vc4 = gallium_drivers.contains('vc4')
166 with_gallium_v3d = gallium_drivers.contains('v3d')
167 with_gallium_panfrost = gallium_drivers.contains('panfrost')
168 with_gallium_etnaviv = gallium_drivers.contains('etnaviv')
169 with_gallium_tegra = gallium_drivers.contains('tegra')
170 with_gallium_crocus = gallium_drivers.contains('crocus')
171 with_gallium_iris = gallium_drivers.contains('iris')
172 with_gallium_i915 = gallium_drivers.contains('i915')
173 with_gallium_svga = gallium_drivers.contains('svga')
174 with_gallium_virgl = gallium_drivers.contains('virgl')
175 with_gallium_lima = gallium_drivers.contains('lima')
176 with_gallium_zink = gallium_drivers.contains('zink')
177 with_gallium_d3d12 = gallium_drivers.contains('d3d12')
178 with_gallium_asahi = gallium_drivers.contains('asahi')
179 foreach gallium_driver : gallium_drivers
180 pre_args += '-DHAVE_@0@'.format(gallium_driver.to_upper())
183 freedreno_kmds = get_option('freedreno-kmds')
184 # If building only vulkan with only kgsl kmd support, there is no libdrm
186 if freedreno_kmds.length() == 1 and freedreno_kmds.contains('kgsl') and not with_gallium_freedreno
187 system_has_kms_drm = false
190 with_gallium = gallium_drivers.length() != 0
191 with_gallium_kmsro = system_has_kms_drm and [
193 with_gallium_etnaviv,
194 with_gallium_freedreno,
196 with_gallium_panfrost,
202 if with_gallium and system_has_kms_drm
203 _glx = get_option('glx')
204 _egl = get_option('egl')
205 if _glx == 'dri' or _egl.enabled() or (_glx == 'disabled' and _egl.allowed())
210 _vulkan_drivers = get_option('vulkan-drivers')
211 if _vulkan_drivers.contains('auto')
212 if system_has_kms_drm
213 if host_machine.cpu_family().startswith('x86')
214 _vulkan_drivers = ['amd', 'intel', 'intel_hasvk', 'swrast']
215 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
216 _vulkan_drivers = ['swrast']
217 elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
218 _vulkan_drivers = ['amd', 'swrast']
219 elif ['loongarch64'].contains(host_machine.cpu_family())
220 _vulkan_drivers = ['amd', 'swrast']
222 error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
223 host_machine.cpu_family()))
225 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
226 # No vulkan driver supports windows or macOS currently
229 error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
230 host_machine.system()))
234 with_intel_vk = _vulkan_drivers.contains('intel')
235 with_intel_hasvk = _vulkan_drivers.contains('intel_hasvk')
236 with_amd_vk = _vulkan_drivers.contains('amd')
237 with_freedreno_vk = _vulkan_drivers.contains('freedreno')
238 with_panfrost_vk = _vulkan_drivers.contains('panfrost')
239 with_swrast_vk = _vulkan_drivers.contains('swrast')
240 with_virtio_vk = _vulkan_drivers.contains('virtio-experimental')
241 with_broadcom_vk = _vulkan_drivers.contains('broadcom')
242 with_imagination_vk = _vulkan_drivers.contains('imagination-experimental')
243 with_imagination_srv = get_option('imagination-srv')
244 with_microsoft_vk = _vulkan_drivers.contains('microsoft-experimental')
245 with_any_vk = _vulkan_drivers.length() != 0
247 with_any_broadcom = with_gallium_vc4 or with_gallium_v3d or with_broadcom_vk
248 with_any_intel = with_intel_vk or with_intel_hasvk or with_gallium_iris or with_gallium_crocus or with_intel_tools
250 if with_swrast_vk and not with_gallium_softpipe
251 error('swrast vulkan requires gallium swrast')
253 if with_gallium_tegra and not with_gallium_nouveau
254 error('tegra driver requires nouveau driver')
256 if with_aco_tests and not with_amd_vk
257 error('ACO tests require Radv')
260 with_microsoft_clc = get_option('microsoft-clc').enabled()
261 if ['x86_64'].contains(host_machine.cpu_family())
262 with_intel_clc = get_option('intel-clc').enabled()
263 with_intel_vk_rt = with_intel_vk and with_intel_clc
265 with_intel_clc = false
266 with_intel_vk_rt = false
268 with_clc = with_microsoft_clc or with_intel_clc
269 with_libclc = with_clc
270 with_spirv_to_dxil = get_option('spirv-to-dxil')
272 if host_machine.system() == 'darwin'
273 with_dri_platform = 'apple'
274 pre_args += '-DBUILDING_MESA'
275 elif ['windows', 'cygwin'].contains(host_machine.system())
276 with_dri_platform = 'windows'
277 elif system_has_kms_drm
278 with_dri_platform = 'drm'
280 # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
281 # assert here that one of those cases has been met.
282 # FIXME: illumos ends up here as well
283 with_dri_platform = 'none'
286 with_vulkan_beta = get_option('vulkan-beta')
287 if host_machine.system() == 'darwin'
288 #macOS seems to need beta extensions to build for now:
289 with_vulkan_beta = true
292 pre_args += '-DVK_ENABLE_BETA_EXTENSIONS'
295 _codecs = get_option('video-codecs')
296 foreach c : ['vc1dec', 'h264dec', 'h264enc', 'h265dec', 'h265enc']
297 pre_args += '-DVIDEO_CODEC_@0@=@1@'.format(c.to_upper(), _codecs.contains(c).to_int())
300 _platforms = get_option('platforms')
301 if _platforms.contains('auto')
302 if system_has_kms_drm
303 _platforms = ['x11', 'wayland']
304 elif ['darwin', 'cygwin'].contains(host_machine.system())
306 elif ['haiku'].contains(host_machine.system())
307 _platforms = ['haiku']
308 elif host_machine.system() == 'windows'
309 _platforms = ['windows']
311 error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format(
312 host_machine.system()))
316 with_platform_android = _platforms.contains('android')
317 with_platform_x11 = _platforms.contains('x11')
318 with_platform_wayland = _platforms.contains('wayland')
319 with_platform_haiku = _platforms.contains('haiku')
320 with_platform_windows = _platforms.contains('windows')
322 with_glx = get_option('glx')
323 if with_glx == 'auto'
325 with_glx = 'disabled'
326 elif with_platform_android
327 with_glx = 'disabled'
330 elif with_platform_haiku
331 with_glx = 'disabled'
332 elif host_machine.system() == 'windows'
333 with_glx = 'disabled'
335 # Even when building just gallium drivers the user probably wants dri
337 elif with_platform_x11 and with_any_opengl and not with_any_vk
338 # The automatic behavior should not be to turn on xlib based glx when
339 # building only vulkan drivers
342 with_glx = 'disabled'
351 if not with_opengl and with_glx != 'disabled'
352 error('Building GLX without OpenGL is not supported.') \
355 if not (with_dri or with_gallium or with_glx != 'disabled')
359 with_any_opengl = false
360 with_shared_glapi = false
363 with_gbm = get_option('gbm') \
364 .require(system_has_kms_drm, error_message : 'GBM only supports DRM/KMS platforms') \
365 .disable_auto_if(not with_dri) \
368 with_xlib_lease = get_option('xlib-lease') \
369 .require(with_platform_x11 and system_has_kms_drm, error_message : 'xlib-lease requires X11 and KMS/DRM support') \
372 with_egl = get_option('egl') \
373 .require(host_machine.system() != 'darwin', error_message : 'EGL not supported on MacOS') \
374 .require(with_platform_windows or with_platform_haiku or with_dri or with_platform_android, error_message : 'EGL requires DRI, Haiku, Windows or Android') \
375 .require(with_shared_glapi, error_message : 'EGL requires shared-glapi') \
376 .require(with_glx != 'xlib', error_message :'EGL requires DRI, but GLX is being built with xlib support') \
377 .disable_auto_if(with_platform_haiku) \
381 _platforms += 'surfaceless'
382 if with_gbm and not with_platform_android
386 egl_native_platform = get_option('egl-native-platform')
387 if egl_native_platform.contains('auto')
388 egl_native_platform = _platforms[0]
392 if with_egl and not _platforms.contains(egl_native_platform)
393 error('-Degl-native-platform does not specify an enabled platform')
396 if 'x11' in _platforms
400 foreach platform : _platforms
401 pre_args += '-DHAVE_@0@_PLATFORM'.format(platform.to_upper())
404 if with_platform_android and get_option('platform-sdk-version') >= 29
405 # By default the NDK compiler, at least, emits emutls references instead of
406 # ELF TLS, even when building targeting newer API levels. Make it actually do
408 c_cpp_args += '-fno-emulated-tls'
411 # -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires
412 # full toolchain (including libc) support.
413 have_mtls_dialect = false
414 foreach c_arg : get_option('c_args')
415 if c_arg.startswith('-mtls-dialect=')
416 have_mtls_dialect = true
420 if not have_mtls_dialect
421 # need .run to check libc support. meson aborts when calling .run when
422 # cross-compiling, but because this is just an optimization we can skip it
423 if meson.is_cross_build() and not meson.can_run_host_binaries()
424 warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
426 # -fpic to force dynamic tls, otherwise TLS relaxation defeats check
427 gnu2_test = cc.run('int __thread x; int main() { return x; }',
428 args: ['-mtls-dialect=gnu2', '-fpic'],
429 name: '-mtls-dialect=gnu2')
430 if gnu2_test.returncode() == 0 and (
431 # check for lld 13 bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
432 host_machine.cpu_family() != 'x86_64' or
433 # get_linker_id misses LDFLAGS=-fuse-ld=lld: https://github.com/mesonbuild/meson/issues/6377
434 #cc.get_linker_id() != 'ld.lld' or
435 cc.links('''int __thread x; int y; int main() { __asm__(
436 "leaq x@TLSDESC(%rip), %rax\n"
437 "movq y@GOTPCREL(%rip), %rdx\n"
438 "call *x@TLSCALL(%rax)\n"); }''', name: 'split TLSDESC')
440 c_cpp_args += '-mtls-dialect=gnu2'
445 if with_glx != 'disabled'
446 if not (with_platform_x11 and with_any_opengl)
447 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
448 elif with_glx == 'xlib'
450 error('xlib based GLX requires at least one gallium driver')
451 elif not with_gallium_softpipe
452 error('xlib based GLX requires softpipe or llvmpipe.')
454 error('xlib conflicts with any dri driver')
456 elif with_glx == 'dri'
457 if not with_shared_glapi
458 error('dri based GLX requires shared-glapi')
463 with_glvnd = get_option('glvnd')
464 glvnd_vendor_name = get_option('glvnd-vendor-name')
466 if with_platform_windows
467 error('glvnd cannot be used on Windows')
468 elif with_glx == 'xlib'
469 error('Cannot build glvnd support for GLX that is not DRI based.')
470 elif with_glx == 'disabled' and not with_egl
471 error('glvnd requires DRI based GLX and/or EGL')
473 if get_option('egl-lib-suffix') != ''
474 error('''EGL lib suffix can't be used with libglvnd''')
478 if with_vulkan_icd_dir == ''
479 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
482 # GNU/Hurd includes egl_dri2, without drm.
483 with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or
484 host_machine.system() == 'gnu')
485 with_dri3 = get_option('dri3').disable_auto_if(not (system_has_kms_drm and with_dri2)).allowed()
487 if with_any_vk and (with_platform_x11 and not with_dri3)
488 error('Vulkan drivers require dri3 for X11 support')
491 if with_glx == 'disabled' and not with_egl and not with_gbm
492 error('building dri drivers require at least one windowing system')
496 if with_gallium_kmsro and (with_platform_x11 and not with_dri3)
497 error('kmsro requires dri3 for X11 support')
500 dep_dxheaders = null_dep
501 if with_gallium_d3d12 or with_microsoft_clc or with_microsoft_vk
502 dep_dxheaders = dependency('directx-headers', required : false)
503 if not dep_dxheaders.found()
504 dep_dxheaders = dependency('DirectX-Headers',
505 version : '>= 1.606.4',
506 fallback : ['DirectX-Headers', 'dep_dxheaders'],
507 required : with_gallium_d3d12 or with_microsoft_vk
512 _with_gallium_d3d12_video = get_option('gallium-d3d12-video')
513 with_gallium_d3d12_video = false
514 if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled()
515 with_gallium_d3d12_video = true
516 pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO'
520 with_gallium_d3d12_video,
521 with_gallium_nouveau,
523 with_gallium_radeonsi,
527 vdpau = get_option('gallium-vdpau') \
528 .require(system_has_kms_drm, error_message : 'VDPAU state tracker can only be build on unix-like OSes.') \
529 .require(with_platform_x11, error_message : 'VDPAU state tracker requires X11 support.') \
530 .require(_vdpau_drivers.contains(true), error_message : 'VDPAU state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).')
532 dep_vdpau = dependency('vdpau', version : '>= 1.1', required : vdpau)
534 dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
535 pre_args += '-DHAVE_ST_VDPAU'
537 with_gallium_vdpau = dep_vdpau.found()
539 vdpau_drivers_path = get_option('vdpau-libs-path')
540 if vdpau_drivers_path == ''
541 vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
544 if with_vulkan_overlay_layer or with_aco_tests or with_amd_vk or with_intel_vk
545 prog_glslang = find_program('glslangValidator', native : true)
546 if run_command(prog_glslang, [ '--quiet', '--version' ], check : false).returncode() == 0
547 glslang_quiet = ['--quiet']
554 _omx = get_option('gallium-omx')
555 if not system_has_kms_drm
556 if ['auto', 'disabled'].contains(_omx)
559 error('OMX state tracker can only be built on unix-like OSes.')
561 elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
562 if ['auto', 'disabled'].contains(_omx)
565 error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
568 with_gallium_omx = _omx
571 if ['auto', 'bellagio'].contains(_omx)
572 dep_omx = dependency(
573 'libomxil-bellagio', required : _omx == 'bellagio'
576 with_gallium_omx = 'bellagio'
579 if ['auto', 'tizonia'].contains(_omx)
580 if with_dri and with_egl
581 dep_omx = dependency(
582 'libtizonia', version : '>= 0.10.0',
583 required : _omx == 'tizonia',
586 dependency('libtizplatform', required : _omx == 'tizonia'),
587 dependency('tizilheaders', required : _omx == 'tizonia'),
589 if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
590 with_gallium_omx = 'tizonia'
592 elif _omx == 'tizonia'
593 error('OMX-Tizonia state tracker requires dri and egl')
597 with_gallium_omx = 'disabled'
599 with_gallium_omx = _omx
603 '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'),
604 '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'),
608 omx_drivers_path = get_option('omx-libs-path')
610 if with_gallium_omx != 'disabled'
611 # Figure out where to put the omx driver.
612 # FIXME: this could all be vastly simplified by adding a 'defined_variable'
613 # argument to meson's get_variable method.
614 if omx_drivers_path == ''
615 _omx_libdir = dep_omx.get_variable(pkgconfig : 'libdir')
616 _omx_drivers_dir = dep_omx.get_variable(pkgconfig : 'pluginsdir')
617 if _omx_libdir == get_option('libdir')
618 omx_drivers_path = _omx_drivers_dir
621 # This will fail on windows. Does OMX run on windows?
622 _omx_libdir = _omx_libdir.split('/')
623 _omx_drivers_dir = _omx_drivers_dir.split('/')
624 foreach o : _omx_drivers_dir
625 if not _omx_libdir.contains(o)
629 omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
635 with_gallium_d3d12_video,
636 with_gallium_nouveau,
638 with_gallium_radeonsi,
642 _va = get_option('gallium-va') \
643 .require(_va_drivers.contains(true),
644 error_message : 'VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video), virgl.')
645 _dep_va_name = host_machine.system() == 'windows' ? 'libva-win32' : 'libva'
646 dep_va = dependency(_dep_va_name, version : '>= 1.8.0', required : _va)
648 dep_va_headers = dep_va.partial_dependency(compile_args : true)
649 if cc.has_header_symbol('va/va.h', 'VASurfaceAttribDRMFormatModifiers',
650 dependencies: dep_va_headers)
651 pre_args += '-DHAVE_VA_SURFACE_ATTRIB_DRM_FORMAT_MODIFIERS'
654 with_gallium_va = dep_va.found()
656 va_drivers_path = get_option('va-libs-path')
657 if va_drivers_path == ''
658 va_drivers_path = join_paths(get_option('libdir'), 'dri')
661 with_gallium_xa = get_option('gallium-xa') \
662 .require(system_has_kms_drm, error_message : 'XA state tracker can only be built on unix-like OSes.') \
663 .require(with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915 or with_gallium_svga,
664 error_message : 'XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.') \
667 d3d_drivers_path = get_option('d3d-drivers-path')
668 if d3d_drivers_path == ''
669 d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d')
672 with_gallium_st_nine = get_option('gallium-nine')
673 if with_gallium_st_nine
674 if not with_gallium_softpipe
675 error('The nine state tracker requires gallium softpipe/llvmpipe.')
678 with_gallium_freedreno,
681 with_gallium_nouveau,
682 with_gallium_panfrost,
685 with_gallium_radeonsi,
689 error('The nine state tracker requires at least one non-swrast gallium driver.')
692 error('Using nine with wine requires dri3')
695 with_gallium_st_d3d10umd = get_option('gallium-d3d10umd')
696 if with_gallium_st_d3d10umd
697 if not with_gallium_softpipe
698 error('The d3d10umd state tracker requires gallium softpipe/llvmpipe.')
701 _power8 = get_option('power8')
703 if host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little'
704 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
705 error('Altivec is not supported with gcc version < 4.8.')
710 vector unsigned char r;
711 vector unsigned int v = vec_splat_u32 (1);
712 r = __builtin_vec_vgbbd ((vector unsigned char) v);
715 args : '-mpower8-vector',
716 name : 'POWER8 intrinsics')
717 pre_args += ['-D_ARCH_PWR8']
718 c_cpp_args += '-mpower8-vector'
719 elif _power8.enabled()
720 error('POWER8 intrinsic support required but not found.')
725 if get_option('vmware-mks-stats')
726 if not with_gallium_svga
727 error('vmware-mks-stats requires gallium VMware/svga driver.')
729 pre_args += '-DVMX86_STATS=1'
732 _opencl = get_option('gallium-opencl')
733 _rtti = get_option('cpp_rtti')
734 if _opencl != 'disabled'
736 error('OpenCL Clover implementation requires at least one gallium driver.')
739 error('The Clover OpenCL state tracker requires rtti')
743 with_gallium_opencl = true
744 with_opencl_icd = _opencl == 'icd'
746 with_gallium_opencl = false
747 with_opencl_icd = false
750 with_gallium_rusticl = get_option('gallium-rusticl')
751 if with_gallium_rusticl
753 error('rusticl requires at least one gallium driver.')
756 if meson.version().version_compare('< 1.0.0')
757 error('rusticl requires meson 1.0.0 or newer')
760 add_languages('rust', required: true)
768 dep_clc = dependency('libclc')
771 gl_pkgconfig_c_flags = []
773 if with_glx == 'xlib'
774 pre_args += '-DUSE_XSHM'
776 pre_args += '-DGLX_INDIRECT_RENDERING'
778 pre_args += '-DGLX_DIRECT_RENDERING'
780 if with_dri_platform == 'drm'
781 pre_args += '-DGLX_USE_DRM'
782 elif with_dri_platform == 'apple'
783 pre_args += '-DGLX_USE_APPLEGL'
784 elif with_dri_platform == 'windows'
785 pre_args += '-DGLX_USE_WINDOWSGL'
790 with_android_stub = get_option('android-stub')
791 if with_android_stub and not with_platform_android
792 error('`-D android-stub=true` makes no sense without `-D platforms=android`')
795 with_libbacktrace = get_option('android-libbacktrace') \
796 .require(with_platform_android, error_message : '`-D android-libbacktrace=enabled` makes no sense without `-D platforms=android`') \
797 .disable_auto_if(not with_platform_android) \
801 cpp_args += '-DWITH_LIBBACKTRACE'
804 if with_platform_android
805 dep_android_mapper4 = null_dep
806 if not with_android_stub
808 dependency('cutils'),
809 dependency('hardware'),
813 dep_android += dependency('backtrace')
815 if get_option('platform-sdk-version') >= 26
816 dep_android += dependency('nativewindow')
818 if get_option('platform-sdk-version') >= 30
819 dep_android_mapper4 = dependency('android.hardware.graphics.mapper', version : '>= 4.0', required : false)
824 '-DANDROID_API_LEVEL=' + get_option('platform-sdk-version').to_string()
828 # On Android, seccomp kills the process on kernels without
829 # CONFIG_KCMP/CONFIG_CHECKPOINT_RESTORE if it attemps to use KCMP.
830 # Since we can't detect that, err on the side of caution and disable
831 # KCMP by default on Android.
832 if get_option('allow-kcmp') \
833 .disable_auto_if(with_platform_android) \
835 pre_args += '-DALLOW_KCMP'
838 prog_python = import('python').find_installation('python3')
839 has_mako = run_command(
842 from distutils.version import StrictVersion
844 assert StrictVersion(mako.__version__) > StrictVersion("0.8.0")
846 if has_mako.returncode() != 0
847 error('Python (3.x) mako module >= 0.8.0 required to build mesa.')
850 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
851 error('When using GCC, version 4.4.6 or later is required.')
854 # Support systems without ETIME (e.g. FreeBSD)
855 if cc.get_define('ETIME', prefix : '#include <errno.h>') == ''
856 pre_args += '-DETIME=ETIMEDOUT'
859 # Define DEBUG for debug builds only (debugoptimized is not included on this one)
860 if get_option('buildtype') == 'debug'
861 pre_args += '-DDEBUG'
864 with_shader_cache = get_option('shader-cache') \
865 .require(host_machine.system() != 'windows', error_message : 'Shader Cache does not currently work on Windows') \
869 pre_args += '-DENABLE_SHADER_CACHE'
870 if not get_option('shader-cache-default')
871 pre_args += '-DSHADER_CACHE_DISABLE_BY_DEFAULT'
874 shader_cache_max_size = get_option('shader-cache-max-size')
875 if shader_cache_max_size != ''
876 pre_args += '-DMESA_SHADER_CACHE_MAX_SIZE="@0@"'.format(shader_cache_max_size)
880 # Check for GCC style builtins
881 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
882 'ffsll', 'popcount', 'popcountll', 'unreachable', 'types_compatible_p']
883 if cc.has_function(b)
884 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
888 # check for GCC __attribute__
890 'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result',
891 'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn',
893 foreach a : cc.get_supported_function_attributes(_attributes)
894 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
896 if cc.has_function_attribute('visibility:hidden')
897 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
899 if cc.compiles('__uint128_t foo(void) { return 0; }',
900 name : '__uint128_t')
901 pre_args += '-DHAVE_UINT128'
904 if cc.has_function('reallocarray')
905 pre_args += '-DHAVE_REALLOCARRAY'
907 if cc.has_function('fmemopen')
908 pre_args += '-DHAVE_FMEMOPEN'
911 # TODO: this is very incomplete
912 if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku', 'android'].contains(host_machine.system())
913 pre_args += '-D_GNU_SOURCE'
914 elif host_machine.system() == 'sunos'
915 pre_args += '-D__EXTENSIONS__'
916 elif host_machine.system() == 'windows'
918 '-D_WINDOWS', '-D_WIN32_WINNT=0x0A00', '-DWINVER=0x0A00',
919 '-DPIPE_SUBSYSTEM_WINDOWS_USER',
920 '-D_USE_MATH_DEFINES', # XXX: scons didn't use this for mingw
922 if cc.get_argument_syntax() == 'msvc'
925 '-D_CRT_SECURE_NO_WARNINGS',
926 '-D_CRT_SECURE_NO_DEPRECATE',
927 '-D_SCL_SECURE_NO_WARNINGS',
928 '-D_SCL_SECURE_NO_DEPRECATE',
929 '-D_ALLOW_KEYWORD_MACROS',
930 '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
934 # When the target is not mingw/ucrt
935 # NOTE: clang's stddef.h are conflict with mingw/ucrt's stddef.h
936 # So do not include headers that defined in clang for detecting
940 #if defined(__MINGW32__) && defined(_UCRT)
943 int main(void) { return 0; }''')
944 pre_args += ['-D__MSVCRT_VERSION__=0x0700']
947 elif host_machine.system() == 'openbsd'
948 pre_args += '-D_ISOC11_SOURCE'
951 # Check for generic C arguments
952 c_msvc_compat_args = []
953 no_override_init_args = []
954 cpp_msvc_compat_args = []
955 ld_args_gc_sections = []
956 if cc.get_argument_syntax() == 'msvc'
958 '/wd4018', # signed/unsigned mismatch
959 '/wd4056', # overflow in floating-point constant arithmetic
960 '/wd4244', # conversion from 'type1' to 'type2', possible loss of data
961 '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data
962 '/wd4305', # truncation from 'type1' to 'type2'
963 '/wd4351', # new behavior: elements of array 'array' will be default initialized
964 '/wd4756', # overflow in constant arithmetic
965 '/wd4800', # forcing value to bool 'true' or 'false' (performance warning)
966 '/wd4996', # disabled deprecated POSIX name warnings
967 '/wd4291', # no matching operator delete found
968 '/wd4146', # unary minus operator applied to unsigned type, result still unsigned
969 '/wd4200', # nonstandard extension used: zero-sized array in struct/union
970 '/wd4624', # destructor was implicitly defined as deleted [from LLVM]
971 '/wd4309', # 'initializing': truncation of constant value
972 '/wd4838', # conversion from 'int' to 'const char' requires a narrowing conversion
973 '/wd5105', # macro expansion producing 'defined' has undefined behavior (winbase.h, need Windows SDK upgrade)
974 '/we4020', # Error when passing the wrong number of parameters
975 '/we4024', # Error when passing different type of parameter
976 '/we4189', # 'identifier' : local variable is initialized but not referenced
977 '/Zc:__cplusplus', #Set __cplusplus macro to match the /std:c++<version> on the command line
979 c_args += cc.get_supported_arguments(_trial)
980 cpp_args += cpp.get_supported_arguments(_trial)
983 '-Werror=implicit-function-declaration',
984 '-Werror=missing-prototypes',
985 '-Werror=return-type',
986 '-Werror=empty-body',
987 '-Werror=incompatible-pointer-types',
988 '-Werror=int-conversion',
989 '-Wimplicit-fallthrough',
990 '-Wmisleading-indentation',
991 '-Wno-missing-field-initializers',
992 '-Wno-format-truncation',
993 '-Wno-nonnull-compare',
995 '-fno-trapping-math',
996 '-Qunused-arguments',
999 '-Wno-microsoft-enum-value',
1000 '-Wno-unused-function',
1003 '-Werror=return-type',
1004 '-Werror=empty-body',
1005 '-Wmisleading-indentation',
1006 '-Wno-non-virtual-dtor',
1007 '-Wno-missing-field-initializers',
1008 '-Wno-format-truncation',
1010 '-fno-trapping-math',
1011 '-Qunused-arguments',
1012 # Some classes use custom new operator which zeroes memory, however
1013 # gcc does aggressive dead-store elimination which threats all writes
1014 # to the memory before the constructor as "dead stores".
1015 # For now we disable this optimization.
1018 '-Wno-microsoft-enum-value',
1021 # MinGW chokes on format specifiers and I can't get it all working
1022 if not (cc.get_argument_syntax() == 'gcc' and host_machine.system() == 'windows')
1023 _trial_c += ['-Werror=format', '-Wformat-security']
1024 _trial_cpp += ['-Werror=format', '-Wformat-security']
1027 # FreeBSD annotated <pthread.h> but Mesa isn't ready
1028 if not (cc.get_id() == 'clang' and host_machine.system() == 'freebsd')
1029 _trial_c += ['-Werror=thread-safety']
1032 # If the compiler supports it, put function and data symbols in their
1033 # own sections and GC the sections after linking. This lets drivers
1034 # drop shared code unused by that specific driver (particularly
1035 # relevant for Vulkan drivers).
1036 if cc.links('static char unused() { return 5; } int main() { return 0; }',
1037 args : '-Wl,--gc-sections', name : 'gc-sections')
1038 ld_args_gc_sections += '-Wl,--gc-sections'
1039 _trial_c += ['-ffunction-sections', '-fdata-sections']
1040 _trial_cpp += ['-ffunction-sections', '-fdata-sections']
1043 # Variables that are only used for assertions are considered unused when assertions
1044 # are disabled. Don't treat this as an error, since we build with -Werror even if
1045 # assertions are disabled.
1046 if get_option('b_ndebug') == 'true' or (get_option('buildtype') == 'release' and get_option('b_ndebug') == 'if-release')
1047 _trial_c += ['-Wno-unused-variable', '-Wno-unused-but-set-variable', '/wd4189']
1048 _trial_cpp += ['-Wno-unused-variable', '-Wno-unused-but-set-variable', '/wd4189']
1051 c_args += cc.get_supported_arguments(_trial_c)
1052 cpp_args += cpp.get_supported_arguments(_trial_cpp)
1054 no_override_init_args += cc.get_supported_arguments(
1055 ['-Wno-override-init', '-Wno-initializer-overrides']
1058 # Check for C and C++ arguments for MSVC compatibility. These are only used
1059 # in parts of the mesa code base that need to compile with MSVC, mainly
1061 _trial_msvc = ['-Werror=pointer-arith', '-Werror=vla', '-Werror=gnu-empty-initializer']
1062 c_msvc_compat_args += cc.get_supported_arguments(_trial_msvc)
1063 cpp_msvc_compat_args += cpp.get_supported_arguments(_trial_msvc)
1066 # set linker arguments
1067 if host_machine.system() == 'windows'
1068 if cc.get_argument_syntax() == 'msvc'
1069 add_project_link_arguments(
1073 language : ['c', 'cpp'],
1075 if get_option('buildtype') != 'debug'
1076 add_project_link_arguments(
1078 language : ['c', 'cpp'],
1082 add_project_link_arguments(
1083 cc.get_supported_link_arguments(
1085 '-Wl,--dynamicbase',
1087 '-static-libstdc++',
1091 add_project_link_arguments(
1092 cpp.get_supported_link_arguments(
1094 '-Wl,--dynamicbase',
1096 '-static-libstdc++',
1107 if host_machine.cpu_family().startswith('x86')
1108 pre_args += '-DUSE_SSE41'
1111 if cc.get_id() != 'msvc'
1112 sse41_args = ['-msse4.1']
1114 if host_machine.cpu_family() == 'x86'
1115 # x86_64 have sse2 by default, so sse2 args only for x86
1116 sse2_arg = ['-msse2', '-mfpmath=sse']
1117 sse2_args = [sse2_arg, '-mstackrealign']
1118 if get_option('sse2')
1119 # These settings make generated GCC code match MSVC and follow
1120 # GCC advice on https://gcc.gnu.org/wiki/FloatingPointMath#x86note
1122 # NOTE: We need to ensure stack is realigned given that we
1123 # produce shared objects, and have no control over the stack
1124 # alignment policy of the application. Therefore we need
1125 # -mstackrealign or -mincoming-stack-boundary=2.
1127 # XXX: We could have SSE without -mstackrealign if we always used
1128 # __attribute__((force_align_arg_pointer)), but that's not
1130 c_cpp_args += sse2_args
1131 # sse2_args are adopted into c_cpp_args to avoid duplicated sse2 command line args
1135 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
1136 # that's not guaranteed
1137 sse41_args += '-mstackrealign'
1143 # Check for GCC style atomics
1144 dep_atomic = null_dep
1146 if cc.compiles('''#include <stdint.h>
1151 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1152 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1155 name : 'GCC atomic builtins')
1156 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
1158 # Not all atomic calls can be turned into lock-free instructions, in which
1159 # GCC will make calls into the libatomic library. Check whether we need to
1160 # link with -latomic.
1162 # This can happen for 64-bit atomic operations on 32-bit architectures such
1164 if not cc.links('''#include <stdint.h>
1169 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1170 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1172 name : 'GCC atomic builtins required -latomic')
1173 dep_atomic = cc.find_library('atomic')
1176 if not cc.links('''#include <stdint.h>
1179 return __sync_add_and_fetch(&v, (uint64_t)1);
1181 dependencies : dep_atomic,
1182 name : 'GCC 64bit atomics')
1183 pre_args += '-DMISSING_64BIT_ATOMICS'
1186 dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows)
1188 # TODO: shared/static? Is this even worth doing?
1191 if host_machine.cpu_family() == 'x86'
1192 if system_has_kms_drm or host_machine.system() == 'gnu'
1193 with_asm_arch = 'x86'
1194 pre_args += ['-DUSE_X86_ASM']
1196 if with_glx_read_only_text
1197 pre_args += ['-DGLX_X86_READONLY_TEXT']
1200 elif host_machine.cpu_family() == 'x86_64'
1201 if system_has_kms_drm
1202 with_asm_arch = 'x86_64'
1203 pre_args += ['-DUSE_X86_64_ASM']
1205 elif host_machine.cpu_family() == 'arm'
1206 if system_has_kms_drm
1207 with_asm_arch = 'arm'
1208 pre_args += ['-DUSE_ARM_ASM']
1210 elif host_machine.cpu_family() == 'aarch64'
1211 if system_has_kms_drm
1212 with_asm_arch = 'aarch64'
1213 pre_args += ['-DUSE_AARCH64_ASM']
1215 elif host_machine.cpu_family() == 'sparc64'
1216 if system_has_kms_drm
1217 with_asm_arch = 'sparc'
1218 pre_args += ['-DUSE_SPARC_ASM']
1220 elif host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little'
1221 if system_has_kms_drm
1222 with_asm_arch = 'ppc64le'
1223 pre_args += ['-DUSE_PPC64LE_ASM']
1225 elif host_machine.cpu_family() == 'mips64' and host_machine.endian() == 'little'
1226 if system_has_kms_drm
1227 with_asm_arch = 'mips64el'
1228 pre_args += ['-DUSE_MIPS64EL_ASM']
1230 elif host_machine.cpu_family() == 'loongarch64'
1231 if system_has_kms_drm
1232 with_asm_arch = 'loongarch64'
1233 pre_args += ['-DUSE_LOONGARCH64_ASM']
1237 # Check for standard headers and functions
1238 if (cc.has_header_symbol('sys/sysmacros.h', 'major') and
1239 cc.has_header_symbol('sys/sysmacros.h', 'minor') and
1240 cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
1241 pre_args += '-DMAJOR_IN_SYSMACROS'
1243 if (cc.has_header_symbol('sys/mkdev.h', 'major') and
1244 cc.has_header_symbol('sys/mkdev.h', 'minor') and
1245 cc.has_header_symbol('sys/mkdev.h', 'makedev'))
1246 pre_args += '-DMAJOR_IN_MKDEV'
1249 if cc.check_header('sched.h')
1250 pre_args += '-DHAS_SCHED_H'
1251 if cc.has_function('sched_getaffinity')
1252 pre_args += '-DHAS_SCHED_GETAFFINITY'
1256 if not ['linux'].contains(host_machine.system())
1257 # Deprecated on Linux and requires <sys/types.h> on FreeBSD and OpenBSD
1258 if cc.check_header('sys/sysctl.h', prefix : '#include <sys/types.h>')
1259 pre_args += '-DHAVE_SYS_SYSCTL_H'
1263 foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h',
1264 'cet.h', 'pthread_np.h', 'renderdoc_app.h', 'sys/inotify.h']
1265 if cc.check_header(h)
1266 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
1270 functions_to_detect = {
1273 'timespec_get': '#include <time.h>',
1282 foreach f, prefix: functions_to_detect
1283 if cc.has_function(f, prefix: prefix)
1284 pre_args += '-DHAVE_@0@'.format(f.to_upper())
1292 static int dcomp(const void *l, const void *r, void *t) { return 0; }
1294 int main(int ac, char **av) {
1297 qsort_r((void*)&arr[0], 1, 1, dcomp, t);
1301 name : 'GNU qsort_r')
1302 pre_args += '-DHAVE_GNU_QSORT_R'
1306 static int dcomp(void *t, const void *l, const void *r) { return 0; }
1308 int main(int ac, char **av) {
1311 qsort_r((void*)&arr[0], 1, 1, t, dcomp);
1315 name : 'BSD qsort_r')
1316 pre_args += '-DHAVE_BSD_QSORT_R'
1319 if cc.has_header_symbol('time.h', 'struct timespec')
1320 pre_args += '-DHAVE_STRUCT_TIMESPEC'
1323 with_c11_threads = false
1324 if cc.has_function('thrd_create', prefix: '#include <threads.h>')
1325 if with_platform_android
1326 # Current only Android's c11 <threads.h> are verified
1327 pre_args += '-DHAVE_THRD_CREATE'
1328 with_c11_threads = true
1332 if cc.has_header_symbol('errno.h', 'program_invocation_name',
1333 args : '-D_GNU_SOURCE')
1334 pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'
1335 elif with_tools.contains('intel')
1336 error('Intel tools require the program_invocation_name variable')
1339 if cc.has_header_symbol('math.h', 'issignaling',
1340 args : '-D_GNU_SOURCE')
1341 pre_args += '-DHAVE_ISSIGNALING'
1344 # MinGW provides a __builtin_posix_memalign function, but not a posix_memalign.
1345 # This means that this check will succeed, but then compilation will later
1346 # fail. MSVC doesn't have this function at all, so only check for it on
1347 # non-windows platforms.
1348 if host_machine.system() != 'windows'
1349 if cc.has_function('posix_memalign')
1350 pre_args += '-DHAVE_POSIX_MEMALIGN'
1354 if cc.has_member('struct dirent', 'd_type', prefix: '''#include <sys/types.h>
1355 #include <dirent.h>''')
1356 pre_args += '-DHAVE_DIRENT_D_TYPE'
1359 # strtod locale support
1364 #ifdef HAVE_XLOCALE_H
1365 #include <xlocale.h>
1368 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
1369 const char *s = "1.0";
1371 double d = strtod_l(s, end, loc);
1372 float f = strtof_l(s, end, loc);
1377 name : 'strtod has locale support')
1378 pre_args += '-DHAVE_STRTOD_L'
1381 # Check for some linker flags
1382 ld_args_bsymbolic = []
1383 if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
1384 ld_args_bsymbolic += '-Wl,-Bsymbolic'
1386 with_ld_version_script = false
1387 if cc.links('int main() { return 0; }',
1388 args : '-Wl,--version-script=@0@'.format(
1389 join_paths(meson.current_source_dir(), 'build-support/conftest.map')),
1390 name : 'version-script')
1391 with_ld_version_script = true
1393 with_ld_dynamic_list = false
1394 if cc.links('int main() { return 0; }',
1395 args : '-Wl,--dynamic-list=@0@'.format(
1396 join_paths(meson.current_source_dir(), 'build-support/conftest.dyn')),
1397 name : 'dynamic-list')
1398 with_ld_dynamic_list = true
1401 ld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1')
1403 # check for dl support
1405 if host_machine.system() != 'windows'
1406 if not cc.has_function('dlopen')
1407 dep_dl = cc.find_library('dl', required : true)
1409 if cc.has_function('dladdr', dependencies : dep_dl)
1410 # This is really only required for util/disk_cache.h
1411 pre_args += '-DHAVE_DLADDR'
1415 if cc.has_function('dl_iterate_phdr')
1416 pre_args += '-DHAVE_DL_ITERATE_PHDR'
1417 elif with_intel_vk or with_intel_hasvk
1418 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
1421 # only used in Iris and ANV
1422 if with_any_intel and ['x86', 'x86_64'].contains(host_machine.cpu_family())
1423 pre_args += '-DSUPPORT_INTEL_INTEGRATED_GPUS'
1426 if get_option('intel-xe-kmd').enabled()
1427 pre_args += '-DINTEL_XE_KMD_SUPPORTED'
1430 if with_intel_hasvk and host_machine.cpu_family().startswith('x86') == false
1431 error('Intel "hasvk" Vulkan driver requires x86 or x86_64 CPU family')
1434 if with_gallium_crocus and host_machine.cpu_family().startswith('x86') == false
1435 error('Intel "crocus" Gallium driver requires x86 or x86_64 CPU family')
1438 if with_gallium_i915 and host_machine.cpu_family().startswith('x86') == false
1439 error('Intel "i915" Gallium driver requires x86 or x86_64 CPU family')
1442 # Determine whether or not the rt library is needed for time functions
1443 if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
1444 dep_clock = null_dep
1446 dep_clock = cc.find_library('rt')
1449 dep_zlib = dependency('zlib', version : '>= 1.2.3',
1450 fallback : ['zlib', 'zlib_dep'],
1451 required : get_option('zlib'))
1453 pre_args += '-DHAVE_ZLIB'
1456 dep_zstd = dependency('libzstd', required : get_option('zstd'))
1458 pre_args += '-DHAVE_ZSTD'
1461 with_compression = dep_zlib.found() or dep_zstd.found()
1463 pre_args += '-DHAVE_COMPRESSION'
1464 elif with_shader_cache
1465 error('Shader Cache requires compression')
1468 if host_machine.system() == 'windows'
1469 # For MSVC and MinGW we aren't using pthreads, and dependency('threads') will add linkage
1470 # to pthread for MinGW, so leave the dependency null_dep for Windows. For Windows linking to
1471 # kernel32 is enough for c11/threads.h and it's already linked by meson by default
1472 dep_thread = null_dep
1474 dep_thread = dependency('threads')
1476 if dep_thread.found()
1477 pre_args += '-DHAVE_PTHREAD'
1478 if host_machine.system() != 'netbsd' and cc.has_function(
1479 'pthread_setaffinity_np',
1480 dependencies : dep_thread,
1481 prefix : '#include <pthread.h>',
1482 args : '-D_GNU_SOURCE')
1483 pre_args += '-DHAVE_PTHREAD_SETAFFINITY'
1487 # We don't have expat on Android or Windows, which is a needed dep for xmlconfig
1488 opt_xmlconfig = get_option('xmlconfig') \
1489 .require(not (with_platform_android or with_platform_windows),
1490 error_message : 'xmlconfig not available on Android or Windows')
1492 if host_machine.system() == 'darwin'
1493 dep_expat = meson.get_compiler('c').find_library('expat', required : opt_xmlconfig)
1495 dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'],
1496 required : opt_xmlconfig)
1498 use_xmlconfig = dep_expat.found()
1500 # Predefined macros for windows
1501 if host_machine.system() == 'windows'
1502 pre_args += '-DWIN32_LEAN_AND_MEAN' # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx
1504 # this only exists on linux so either this is linux and it will be found, or
1505 # it's not linux and wont
1506 dep_m = cc.find_library('m', required : false)
1508 if host_machine.system() == 'windows'
1509 dep_regex = meson.get_compiler('c').find_library('regex', required : false)
1510 if not dep_regex.found()
1511 dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
1514 dep_regex = null_dep
1517 if with_platform_haiku
1518 dep_network = cc.find_library('network')
1521 dep_futex = null_dep
1522 if host_machine.system() == 'windows'
1523 if (get_option('min-windows-version') < 8)
1524 pre_args += '-DWINDOWS_NO_FUTEX'
1526 dep_futex = cc.find_library('synchronization', required : true)
1530 # Check for libdrm. Various drivers have different libdrm version requirements,
1531 # but we always want to use the same version for all libdrm modules. That means
1532 # even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and
1533 # bar are both on use 2.4.3 for both of them
1534 dep_libdrm_amdgpu = null_dep
1535 dep_libdrm_radeon = null_dep
1536 dep_libdrm_nouveau = null_dep
1537 dep_libdrm_intel = null_dep
1539 _drm_amdgpu_ver = '2.4.110'
1540 _drm_radeon_ver = '2.4.71'
1541 _drm_nouveau_ver = '2.4.102'
1542 _drm_intel_ver = '2.4.75'
1543 _drm_ver = '2.4.109'
1546 ['intel', with_gallium_i915],
1547 ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi],
1548 ['radeon', (with_gallium_radeonsi or with_gallium_r300 or with_gallium_r600)],
1549 ['nouveau', with_gallium_nouveau],
1552 # Loop over the enables versions and get the highest libdrm requirement for all
1555 foreach d : _libdrm_checks
1556 ver = get_variable('_drm_@0@_ver'.format(d[0]))
1557 if d[1] and ver.version_compare('>' + _drm_ver)
1563 message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame))
1566 # Then get each libdrm module
1567 foreach d : _libdrm_checks
1570 'dep_libdrm_' + d[0],
1571 dependency('libdrm_' + d[0], version : '>=' + _drm_ver)
1576 with_gallium_drisw_kms = false
1577 if system_has_kms_drm
1578 dep_libdrm = dependency(
1579 'libdrm', version : '>=' + _drm_ver,
1580 # GNU/Hurd includes egl_dri2, without drm.
1581 required : (with_dri2 and host_machine.system() != 'gnu') or with_dri3
1584 # We should prevent libdrm from being available when the target doesn't have it to avoid transitive
1585 # dependencies (such as vk-runtime) linking to it
1586 dep_libdrm = null_dep
1588 if dep_libdrm.found()
1589 pre_args += '-DHAVE_LIBDRM'
1590 if with_dri_platform == 'drm' and with_dri
1591 with_gallium_drisw_kms = true
1595 dep_libudev = dependency('libudev', required : false)
1596 if dep_libudev.found()
1597 pre_args += '-DHAVE_LIBUDEV'
1600 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit', 'core', 'executionengine', 'scalaropts', 'transformutils', 'instcombine']
1601 llvm_optional_modules = ['coroutines']
1602 if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
1603 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
1604 if with_gallium_r600
1605 llvm_modules += 'asmparser'
1608 if with_gallium_opencl
1610 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
1611 'lto', 'option', 'objcarcopts', 'profiledata'
1613 # all-targets is needed to support static linking LLVM build with multiple targets
1614 # windowsdriver is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet
1615 llvm_optional_modules += ['all-targets', 'frontendopenmp', 'windowsdriver']
1618 llvm_modules += ['coverage', 'target', 'linker', 'irreader', 'option', 'libdriver', 'lto']
1619 # all-targets is needed to support static linking LLVM build with multiple targets
1620 # windowsdriver is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet
1621 llvm_optional_modules += ['all-targets', 'windowsdriver']
1623 draw_with_llvm = get_option('draw-use-llvm')
1625 llvm_modules += 'native'
1626 # lto is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet
1627 llvm_optional_modules += ['lto']
1631 _llvm_version = '>= 13.0.0'
1632 elif with_amd_vk or with_gallium_radeonsi or with_gallium_opencl
1633 _llvm_version = '>= 11.0.0'
1635 _llvm_version = '>= 10.0.0'
1637 _llvm_version = '>= 5.0.0'
1640 _shared_llvm = get_option('shared-llvm') \
1641 .disable_auto_if(host_machine.system() == 'windows') \
1644 _llvm = get_option('llvm')
1648 dep_llvm = dependency(
1650 version : _llvm_version,
1651 modules : llvm_modules,
1652 optional_modules : llvm_optional_modules,
1654 with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or with_clc
1657 static : not _shared_llvm,
1658 fallback : ['llvm', 'dep_llvm'],
1659 include_type : 'system',
1661 with_llvm = dep_llvm.found()
1664 pre_args += '-DLLVM_AVAILABLE'
1665 pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version())
1666 pre_args += '-DLLVM_IS_SHARED=@0@'.format(_shared_llvm.to_int())
1669 pre_args += '-DDRAW_LLVM_AVAILABLE'
1671 error('Lavapipe requires LLVM draw support.')
1674 if host_machine.system() != 'windows'
1675 # LLVM can be built without rtti, turning off rtti changes the ABI of C++
1676 # programs, so we need to build all C++ code in mesa without rtti as well to
1677 # ensure that linking works. Note that Win32 compilers does handle mismatching RTTI
1678 # without issues, so only apply this for other compilers.
1679 if dep_llvm.type_name() == 'internal'
1680 _llvm_rtti = subproject('llvm').get_variable('has_rtti', true)
1682 # The CMake finder will return 'ON', the llvm-config will return 'YES'
1683 _llvm_rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
1685 if _rtti != _llvm_rtti
1687 error('LLVM was built with RTTI, cannot build Mesa with RTTI disabled. Remove cpp_rtti disable switch or use LLVM built without LLVM_ENABLE_RTTI.')
1689 error('LLVM was built without RTTI, so Mesa must also disable RTTI. Use an LLVM built with LLVM_ENABLE_RTTI or add cpp_rtti=false.')
1694 if cc.get_argument_syntax() == 'msvc'
1695 # Suppress "/DELAYLOAD:ole32.dll/shell32.dll ignored" warnings that LLVM adds
1696 add_project_link_arguments(
1698 language : ['c', 'cpp'],
1701 elif with_amd_vk and with_aco_tests
1702 error('ACO tests require LLVM, but LLVM is disabled.')
1703 elif with_gallium_radeonsi or with_swrast_vk
1704 error('The following drivers require LLVM: RadeonSI, SWR, Lavapipe. One of these is enabled, but LLVM is disabled.')
1705 elif with_gallium_opencl
1706 error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
1708 error('The CLC compiler requires LLVM, but LLVM is disabled.')
1710 draw_with_llvm = false
1713 with_opencl_spirv = (_opencl != 'disabled' and get_option('opencl-spirv')) or with_clc
1714 if with_opencl_spirv
1715 chosen_llvm_version_array = dep_llvm.version().split('.')
1716 chosen_llvm_version_major = chosen_llvm_version_array[0].to_int()
1717 chosen_llvm_version_minor = chosen_llvm_version_array[1].to_int()
1719 # Require an SPIRV-LLVM-Translator version compatible with the chosen LLVM
1722 # This first version check is still needed as maybe LLVM 8.0 was picked but
1723 # we do not want to accept SPIRV-LLVM-Translator 8.0.0.1 as that version
1724 # does not have the required API and those are only available starting from
1726 _llvmspirvlib_min_version = '>= 8.0.1.3'
1728 _llvmspirvlib_min_version = '>= 13.0.0.0'
1731 _llvmspirvlib_version = [
1732 _llvmspirvlib_min_version,
1733 '>= @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor),
1734 '< @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor + 1) ]
1736 dep_spirv_tools = dependency('SPIRV-Tools', required : true, version : '>= 2018.0')
1737 # LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator
1738 dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : _llvmspirvlib_version)
1740 dep_spirv_tools = null_dep
1741 dep_llvmspirvlib = null_dep
1744 dep_clang = null_dep
1746 llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
1748 dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
1750 if not dep_clang.found() or not _shared_llvm
1752 'clangBasic', 'clangAST', 'clangCodeGen', 'clangLex',
1753 'clangDriver', 'clangFrontend', 'clangFrontendTool',
1754 'clangHandleCXX', 'clangHandleLLVM', 'clangSerialization',
1755 'clangSema', 'clangParse', 'clangEdit', 'clangAnalysis'
1757 if dep_llvm.version().version_compare('>= 15.0')
1758 clang_modules += 'clangSupport'
1762 foreach m : clang_modules
1763 dep_clang += cpp.find_library(m, dirs : llvm_libdir, required : true)
1768 # Be explicit about only using this lib on Windows, to avoid picking
1769 # up random libs with the generic name 'libversion'
1770 dep_version = null_dep
1771 if host_machine.system() == 'windows'
1772 dep_version = cpp.find_library('version')
1775 dep_elf = dependency('libelf', required : false)
1776 if not with_platform_windows and not dep_elf.found()
1777 dep_elf = cc.find_library('elf', required : false)
1780 pre_args += '-DUSE_LIBELF'
1783 dep_glvnd = null_dep
1785 dep_glvnd = dependency('libglvnd', version : '>= 1.3.2')
1786 pre_args += '-DUSE_LIBGLVND=1'
1789 dep_valgrind = dependency('valgrind', required : get_option('valgrind'))
1790 if dep_valgrind.found()
1791 pre_args += '-DHAVE_VALGRIND'
1794 # AddressSanitizer's leak reports need all the symbols to be present at exit to
1795 # decode well, which runs afoul of our dlopen()/dlclose()ing of the DRI drivers.
1796 # Set a flag so we can skip the dlclose for asan builds.
1797 if ['address', 'address,undefined'].contains(get_option('b_sanitize'))
1798 asan_c_args = ['-DBUILT_WITH_ASAN=1']
1800 asan_c_args = ['-DBUILT_WITH_ASAN=0']
1803 yacc_is_bison = true
1804 needs_flex_bison = with_any_opengl or with_freedreno_vk or with_intel_tools or with_gallium
1806 if build_machine.system() == 'windows'
1807 # Prefer the winflexbison versions, they're much easier to install and have
1808 # better windows support.
1810 prog_flex = find_program('win_flex', required : false)
1811 if prog_flex.found()
1812 # windows compatibility (uses <io.h> instead of <unistd.h> and _isatty,
1813 # _fileno functions)
1814 prog_flex = [prog_flex, '--wincompat']
1816 prog_flex = [find_program('flex', 'lex', required : needs_flex_bison, disabler : true)]
1818 # Force flex to use const keyword in prototypes, as relies on __cplusplus or
1819 # __STDC__ macro to determine whether it's safe to use const keyword
1820 prog_flex += '-DYY_USE_CONST='
1822 prog_flex_cpp = prog_flex
1823 # Convince win_flex to use <inttypes.h> for C++ files
1824 # Note that we are using a C99 version here rather than C11,
1825 # because using a C11 version can cause the MSVC CRT headers to define
1826 # static_assert to _Static_assert, which breaks other parts of the CRT
1827 prog_flex_cpp += '-D__STDC_VERSION__=199901'
1829 prog_bison = find_program('win_bison', required : false)
1830 if not prog_bison.found()
1831 prog_bison = find_program('bison', 'yacc', required : needs_flex_bison, disabler : true)
1834 prog_bison = find_program('bison', required : false)
1836 if not prog_bison.found()
1837 prog_bison = find_program('byacc', required : needs_flex_bison, disabler : true)
1838 yacc_is_bison = false
1841 # Disable deprecated keyword warnings, since we have to use them for
1842 # old-bison compat. See discussion in
1843 # https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2161
1844 if find_program('bison', required : false, version : '> 2.3').found()
1845 prog_bison = [prog_bison, '-Wno-deprecated']
1848 prog_flex = find_program('flex', required : needs_flex_bison, disabler : true)
1849 prog_flex_cpp = prog_flex
1852 dep_selinux = null_dep
1853 if get_option('selinux')
1854 if get_option('execmem') != true
1855 warning('execmem option is disabled, selinux will not be able to use execmem.')
1857 dep_selinux = dependency('libselinux')
1858 pre_args += '-DMESA_SELINUX'
1861 if get_option('execmem')
1862 pre_args += '-DMESA_EXECMEM'
1865 _libunwind = get_option('libunwind') \
1866 .require(not with_platform_android, error_message : 'Android requires the use of the backtrace library, not libunwind')
1867 if host_machine.system() == 'darwin'
1868 dep_unwind = meson.get_compiler('c').find_library('System', required : _libunwind)
1870 dep_unwind = dependency('libunwind', required : _libunwind)
1872 if dep_unwind.found()
1873 pre_args += '-DHAVE_LIBUNWIND'
1877 if not with_gallium_softpipe
1878 error('OSMesa gallium requires gallium softpipe or llvmpipe.')
1880 if host_machine.system() == 'windows'
1881 osmesa_lib_name = 'osmesa'
1883 osmesa_lib_name = 'OSMesa'
1887 # TODO: symbol mangling
1889 if with_platform_wayland
1890 dep_wl_scanner = dependency('wayland-scanner', native: true)
1891 prog_wl_scanner = find_program(dep_wl_scanner.get_variable(pkgconfig : 'wayland_scanner'))
1892 if dep_wl_scanner.version().version_compare('>= 1.15')
1893 wl_scanner_arg = 'private-code'
1895 wl_scanner_arg = 'code'
1897 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.24')
1898 dep_wayland_client = dependency('wayland-client', version : '>=1.18')
1899 dep_wayland_server = dependency('wayland-server', version : '>=1.18')
1901 dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3')
1902 dep_wayland_egl_headers = dep_wayland_egl.partial_dependency(compile_args : true)
1904 wayland_dmabuf_xml = join_paths(
1905 dep_wl_protocols.get_variable(pkgconfig : 'pkgdatadir'), 'unstable',
1906 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
1908 pre_args += '-DWL_HIDE_DEPRECATED'
1913 dep_xfixes = null_dep
1914 dep_x11_xcb = null_dep
1916 dep_xcb_glx = null_dep
1917 dep_xcb_dri2 = null_dep
1918 dep_xcb_dri3 = null_dep
1919 dep_dri2proto = null_dep
1920 dep_glproto = null_dep
1921 dep_xxf86vm = null_dep
1922 dep_xcb_dri3 = null_dep
1923 dep_xcb_present = null_dep
1924 dep_xcb_sync = null_dep
1925 dep_xcb_xfixes = null_dep
1926 dep_xshmfence = null_dep
1927 dep_xcb_xrandr = null_dep
1928 dep_xcb_shm = null_dep
1929 dep_xlib_xrandr = null_dep
1930 dep_openmp = null_dep
1932 # Even if we find OpenMP, Gitlab CI fails to link with gcc/i386 and clang/anyarch.
1933 if host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc'
1934 dep_openmp = dependency('openmp', required : false)
1935 if dep_openmp.found()
1936 pre_args += ['-DHAVE_OPENMP']
1940 with_dri3_modifiers = false
1941 if with_platform_x11
1942 if with_glx == 'xlib'
1943 dep_x11 = dependency('x11')
1944 dep_xext = dependency('xext')
1945 dep_xcb = dependency('xcb')
1946 dep_xcb_xrandr = dependency('xcb-randr')
1947 elif with_glx == 'dri'
1948 dep_x11 = dependency('x11')
1949 dep_xext = dependency('xext')
1950 dep_xfixes = dependency('xfixes', version : '>= 2.0')
1951 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
1952 dep_xcb_shm = dependency('xcb-shm')
1954 if (with_any_vk or with_glx == 'dri' or with_egl or
1955 (with_gallium_vdpau or with_gallium_va or
1956 with_gallium_omx != 'disabled'))
1957 dep_xcb = dependency('xcb')
1958 dep_x11_xcb = dependency('x11-xcb')
1959 if with_dri_platform == 'drm' and not dep_libdrm.found()
1960 error('libdrm required for gallium video statetrackers when using x11')
1963 if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
1964 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
1967 dep_xcb_dri3 = dependency('xcb-dri3')
1968 dep_xcb_present = dependency('xcb-present')
1969 # until xcb-dri3 has been around long enough to make a hard-dependency:
1970 if (dep_xcb_dri3.version().version_compare('>= 1.13') and
1971 dep_xcb_present.version().version_compare('>= 1.13'))
1972 with_dri3_modifiers = true
1974 dep_xcb_shm = dependency('xcb-shm')
1975 dep_xcb_sync = dependency('xcb-sync')
1976 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
1979 if with_glx == 'dri' or with_glx == 'xlib'
1980 dep_glproto = dependency('glproto', version : '>= 1.4.14')
1982 if with_glx == 'dri'
1983 if with_dri_platform == 'drm'
1984 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
1986 dep_xxf86vm = dependency('xxf86vm')
1992 with_gallium_vdpau or with_gallium_xa or
1993 with_gallium_omx != 'disabled'))
1994 dep_xcb_xfixes = dependency('xcb-xfixes')
1996 if with_xlib_lease or with_any_vk
1997 dep_xcb_xrandr = dependency('xcb-randr')
2000 dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
2005 pre_args += '-DHAVE_DRI'
2008 pre_args += '-DHAVE_DRI2'
2011 pre_args += '-DHAVE_DRI3'
2013 if with_dri3_modifiers
2014 pre_args += '-DHAVE_DRI3_MODIFIERS'
2016 if with_gallium_drisw_kms
2017 pre_args += '-DHAVE_DRISW_KMS'
2020 if get_option('gallium-extra-hud')
2021 pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
2024 dep_lmsensors = cc.find_library('sensors', required : get_option('lmsensors'))
2025 if dep_lmsensors.found()
2026 pre_args += '-DHAVE_LIBSENSORS=1'
2029 _shader_replacement = get_option('custom-shader-replacement')
2030 if _shader_replacement == ''
2032 pre_args += '-DCUSTOM_SHADER_REPLACEMENT'
2035 with_perfetto = get_option('perfetto')
2036 with_datasources = get_option('datasources')
2037 with_any_datasource = with_datasources.length() != 0
2039 dep_perfetto = dependency('perfetto', fallback: ['perfetto', 'dep_perfetto'])
2040 pre_args += '-DHAVE_PERFETTO'
2043 add_project_arguments(pre_args, language : ['c', 'cpp'])
2044 add_project_arguments(c_cpp_args, language : ['c', 'cpp'])
2046 add_project_arguments(c_args, language : ['c'])
2047 add_project_arguments(cpp_args, language : ['cpp'])
2051 if with_glx == 'xlib'
2052 gl_priv_reqs += ['x11', 'xext', 'xcb']
2053 elif with_glx == 'dri'
2055 'x11', 'xext', 'xfixes', 'x11-xcb', 'xcb',
2057 if with_dri_platform == 'drm'
2058 gl_priv_reqs += 'xcb-dri2 >= 1.8'
2060 gl_priv_reqs += 'xxf86vm'
2064 if dep_libdrm.found()
2065 gl_priv_reqs += 'libdrm >= 2.4.75'
2069 if dep_thread.found()
2070 gl_priv_libs += ['-lpthread', '-pthread']
2073 gl_priv_libs += '-lm'
2076 gl_priv_libs += '-ldl'
2079 # FIXME: autotools lists this as incomplete
2082 gbm_priv_libs += '-ldl'
2085 pkg = import('pkgconfig')
2087 if host_machine.system() == 'windows'
2088 prog_dumpbin = find_program('dumpbin', required : false)
2089 with_symbols_check = prog_dumpbin.found() and with_tests
2090 if with_symbols_check
2091 symbols_check_args = ['--dumpbin', prog_dumpbin.full_path()]
2094 prog_nm = find_program('nm')
2095 with_symbols_check = with_tests
2096 symbols_check_args = ['--nm', prog_nm.full_path()]
2099 # This quirk needs to be applied to sources with functions defined in assembly
2100 # as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391
2101 gcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : []
2103 devenv = environment()
2105 dir_compiler_nir = join_paths(meson.current_source_dir(), 'src/compiler/nir/')
2106 dir_source_root = meson.project_source_root()
2113 meson.add_devenv(devenv)
2117 'prefix': get_option('prefix'),
2118 'libdir': get_option('libdir'),
2119 'includedir': get_option('includedir'),
2121 section: 'Directories'
2126 'c_cpp_args': c_cpp_args,
2128 section: 'Common C and C++ arguments'
2133 'OpenGL': with_opengl,
2136 'Shared glapi': with_shared_glapi,
2138 section: 'OpenGL', bool_yn: true
2143 'Platform': with_dri_platform,
2144 'Driver dir': dri_drivers_path,
2146 section: 'DRI', bool_yn: true, list_sep: ' '
2151 'Enabled': with_glx != 'disabled',
2152 'Provider': with_glx == 'disabled' ? 'None' : with_glx
2154 section: 'GLX', bool_yn: true, list_sep: ' '
2157 egl_summary = {'Enabled': with_egl}
2161 egl_drivers += 'builtin:egl_dri2'
2164 egl_drivers += 'builtin:egl_dri3'
2166 if with_platform_windows
2167 egl_drivers += 'builtin:wgl'
2169 egl_summary += {'Drivers': egl_drivers}
2170 egl_summary += {'Platforms': _platforms}
2172 summary(egl_summary, section: 'EGL', bool_yn: true, list_sep: ' ')
2174 gbm_summary = {'Enabled': with_gbm}
2176 gbm_summary += {'Backends path': gbm_backends_path}
2178 summary(gbm_summary, section: 'GBM', bool_yn: true, list_sep: ' ')
2180 vulkan_summary = {'Drivers': _vulkan_drivers.length() != 0 ? _vulkan_drivers : false }
2182 vulkan_summary += {'Platforms': _platforms}
2183 vulkan_summary += {'ICD dir': with_vulkan_icd_dir}
2184 if with_any_vulkan_layers
2185 vulkan_summary += {'Layers': get_option('vulkan-layers')}
2187 vulkan_summary += {'Video codecs': _codecs.length() != 0 ? _codecs : false}
2188 vulkan_summary += {'Ray tracing': with_intel_vk_rt ? 'intel' : false}
2190 summary(vulkan_summary, section: 'Vulkan', bool_yn: true, list_sep: ' ')
2192 llvm_summary = {'Enabled': with_llvm}
2194 llvm_summary += {'Version': dep_llvm.version()}
2196 summary(llvm_summary, section: 'LLVM', bool_yn: true, list_sep: ' ')
2198 gallium_summary = {'Enabled': with_gallium}
2200 gallium_summary += {'Drivers': gallium_drivers}
2201 gallium_summary += {'Platforms': _platforms}
2203 gallium_frontends = ['mesa']
2205 gallium_frontends += 'xa'
2207 if with_gallium_vdpau
2208 gallium_frontends += 'vdpau'
2210 if with_gallium_omx != 'disabled'
2211 gallium_frontends += 'omx' + with_gallium_omx
2214 gallium_frontends += 'va'
2216 if with_gallium_st_nine
2217 gallium_frontends += 'nine'
2219 if with_gallium_opencl
2220 gallium_frontends += 'clover'
2222 if with_gallium_rusticl
2223 gallium_frontends += 'rusticl'
2225 gallium_summary += {'Frontends': gallium_frontends}
2226 gallium_summary += {'Off-screen rendering': with_osmesa ? 'lib' + osmesa_lib_name : false}
2227 gallium_summary += {'HUD lm-sensors': dep_lmsensors.found()}
2229 summary(gallium_summary, section: 'Gallium', bool_yn: true, list_sep: ' ')
2231 perfetto_summary = {'Enabled': with_perfetto}
2232 if with_perfetto and with_any_datasource
2233 perfetto_summary += {'Data source': with_datasources}
2235 summary(perfetto_summary, section: 'Perfetto', bool_yn: true, list_sep: ' ')