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.59',
27 default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++17', 'rust_std=2021']
30 # In recent versions, meson can inject some extra arguments to get richer
31 # results from gtest based tests. Feature was added in 0.55, but requiring
32 # 0.59.2 to include an important fix. See https://github.com/mesonbuild/meson/pull/9283.
33 gtest_test_protocol = 'exitcode'
34 if meson.version().version_compare('>= 0.59.2')
35 gtest_test_protocol = 'gtest'
38 cc = meson.get_compiler('c')
39 cpp = meson.get_compiler('cpp')
41 null_dep = dependency('', required : false)
43 if get_option('layout') != 'mirror'
44 error('`mirror` is the only build directory layout supported')
47 # Arguments for the preprocessor, put these in a separate array from the C and
48 # C++ (cpp in meson terminology) arguments since they need to be added to the
49 # default arguments for both C and C++.
51 '-D__STDC_CONSTANT_MACROS',
52 '-D__STDC_FORMAT_MACROS',
53 '-D__STDC_LIMIT_MACROS',
54 '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
55 '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/-/issues"',
60 with_moltenvk_dir = get_option('moltenvk-dir')
61 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
62 with_tests = get_option('build-tests')
63 with_glcpp_tests = get_option('enable-glcpp-tests')
64 with_aco_tests = get_option('build-aco-tests')
65 with_glx_read_only_text = get_option('glx-read-only-text')
66 with_glx_direct = get_option('glx-direct')
67 with_osmesa = get_option('osmesa')
68 with_vulkan_overlay_layer = get_option('vulkan-layers').contains('overlay')
69 with_vulkan_device_select_layer = get_option('vulkan-layers').contains('device-select')
70 with_tools = get_option('tools')
71 if with_tools.contains('all')
88 with_any_vulkan_layers = get_option('vulkan-layers').length() != 0
89 with_intel_tools = with_tools.contains('intel') or with_tools.contains('intel-ui')
90 with_imgui = with_intel_tools or with_vulkan_overlay_layer
92 dri_drivers_path = get_option('dri-drivers-path')
93 if dri_drivers_path == ''
94 dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
96 dri_search_path = get_option('dri-search-path')
97 if dri_search_path == ''
98 dri_search_path = dri_drivers_path
101 gbm_backends_path = get_option('gbm-backends-path')
102 if gbm_backends_path == ''
103 gbm_backends_path = join_paths(get_option('prefix'), get_option('libdir'), 'gbm')
106 # Default shared glapi off for windows, on elsewhere.
107 with_shared_glapi = get_option('shared-glapi') \
108 .disable_auto_if(host_machine.system() == 'windows') \
111 with_opengl = get_option('opengl')
113 with_gles1 = get_option('gles1') \
114 .require(with_shared_glapi, error_message : 'OpengGL ES 1.x requires shared-glapi') \
115 .require(with_opengl, error_message : 'building OpenGL ES 1.x without OpenGL is not supported.') \
118 with_gles2 = get_option('gles2') \
119 .require(with_shared_glapi, error_message : 'OpengGL ES 2.x requires shared-glapi') \
120 .require(with_opengl, error_message : 'building OpenGL ES 2.x without OpenGL is not supported.') \
123 with_any_opengl = with_opengl or with_gles1 or with_gles2
124 # Only build shared_glapi if at least one OpenGL API is enabled
125 with_shared_glapi = with_shared_glapi and with_any_opengl
127 system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'android'].contains(host_machine.system())
129 with_freedreno_kgsl = get_option('freedreno-kgsl')
130 if with_freedreno_kgsl
131 system_has_kms_drm = false
134 dri_drivers = get_option('dri-drivers')
135 if dri_drivers.length() != 0
136 error('Mesa\'s main branch no longer has any "classic" drivers, use the "amber" branch instead.')
139 gallium_drivers = get_option('gallium-drivers')
140 if gallium_drivers.contains('auto')
141 if system_has_kms_drm
143 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
145 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast',
146 'iris', 'crocus', 'i915'
148 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
150 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau', 'svga',
151 'tegra', 'virgl', 'lima', 'panfrost', 'swrast'
153 elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
155 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'swrast'
158 error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
159 host_machine.cpu_family()))
161 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
162 gallium_drivers = ['swrast']
164 error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
165 host_machine.system()))
168 with_gallium_radeonsi = gallium_drivers.contains('radeonsi')
169 with_gallium_r300 = gallium_drivers.contains('r300')
170 with_gallium_r600 = gallium_drivers.contains('r600')
171 with_gallium_nouveau = gallium_drivers.contains('nouveau')
172 with_gallium_freedreno = gallium_drivers.contains('freedreno')
173 with_gallium_softpipe = gallium_drivers.contains('swrast')
174 with_gallium_vc4 = gallium_drivers.contains('vc4')
175 with_gallium_v3d = gallium_drivers.contains('v3d')
176 with_gallium_panfrost = gallium_drivers.contains('panfrost')
177 with_gallium_etnaviv = gallium_drivers.contains('etnaviv')
178 with_gallium_tegra = gallium_drivers.contains('tegra')
179 with_gallium_crocus = gallium_drivers.contains('crocus')
180 with_gallium_iris = gallium_drivers.contains('iris')
181 with_gallium_i915 = gallium_drivers.contains('i915')
182 with_gallium_svga = gallium_drivers.contains('svga')
183 with_gallium_virgl = gallium_drivers.contains('virgl')
184 with_gallium_lima = gallium_drivers.contains('lima')
185 with_gallium_zink = gallium_drivers.contains('zink')
186 with_gallium_d3d12 = gallium_drivers.contains('d3d12')
187 with_gallium_asahi = gallium_drivers.contains('asahi')
188 foreach gallium_driver : gallium_drivers
189 pre_args += '-DHAVE_@0@'.format(gallium_driver.to_upper())
192 with_gallium = gallium_drivers.length() != 0
193 with_gallium_kmsro = system_has_kms_drm and [
195 with_gallium_etnaviv,
196 with_gallium_freedreno,
198 with_gallium_panfrost,
204 if with_gallium and system_has_kms_drm
205 _glx = get_option('glx')
206 _egl = get_option('egl')
207 if _glx == 'dri' or _egl.enabled() or (_glx == 'disabled' and _egl.allowed())
212 _vulkan_drivers = get_option('vulkan-drivers')
213 if _vulkan_drivers.contains('auto')
214 if system_has_kms_drm
215 if host_machine.cpu_family().startswith('x86')
216 _vulkan_drivers = ['amd', 'intel', 'intel_hasvk', 'swrast']
217 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
218 _vulkan_drivers = ['swrast']
219 elif ['mips', 'mips64', 'riscv32', 'riscv64'].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_freedreno_virtio = get_option('freedreno-virtio')
242 with_broadcom_vk = _vulkan_drivers.contains('broadcom')
243 with_imagination_vk = _vulkan_drivers.contains('imagination-experimental')
244 with_imagination_srv = get_option('imagination-srv')
245 with_microsoft_vk = _vulkan_drivers.contains('microsoft-experimental')
246 with_any_vk = _vulkan_drivers.length() != 0
248 with_any_broadcom = with_gallium_vc4 or with_gallium_v3d or with_broadcom_vk
249 with_any_intel = with_intel_vk or with_intel_hasvk or with_gallium_iris or with_gallium_crocus or with_intel_tools
251 if with_swrast_vk and not with_gallium_softpipe
252 error('swrast vulkan requires gallium swrast')
254 if with_gallium_tegra and not with_gallium_nouveau
255 error('tegra driver requires nouveau driver')
257 if with_aco_tests and not with_amd_vk
258 error('ACO tests require Radv')
261 with_microsoft_clc = get_option('microsoft-clc').enabled()
262 if ['x86_64'].contains(host_machine.cpu_family())
263 with_intel_clc = get_option('intel-clc').enabled()
264 with_intel_vk_rt = with_intel_vk and with_intel_clc
266 with_intel_clc = false
267 with_intel_vk_rt = false
269 with_clc = with_microsoft_clc or with_intel_clc
270 with_libclc = with_clc
271 with_spirv_to_dxil = get_option('spirv-to-dxil')
273 if host_machine.system() == 'darwin'
274 with_dri_platform = 'apple'
275 pre_args += '-DBUILDING_MESA'
276 elif ['windows', 'cygwin'].contains(host_machine.system())
277 with_dri_platform = 'windows'
278 elif system_has_kms_drm
279 with_dri_platform = 'drm'
281 # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
282 # assert here that one of those cases has been met.
283 # FIXME: illumos ends up here as well
284 with_dri_platform = 'none'
287 with_vulkan_beta = get_option('vulkan-beta')
288 if host_machine.system() == 'darwin'
289 #macOS seems to need beta extensions to build for now:
290 with_vulkan_beta = true
293 pre_args += '-DVK_ENABLE_BETA_EXTENSIONS'
296 _codecs = get_option('video-codecs')
297 foreach c : ['vc1dec', 'h264dec', 'h264enc', 'h265dec', 'h265enc']
298 pre_args += '-DVIDEO_CODEC_@0@=@1@'.format(c.to_upper(), _codecs.contains(c).to_int())
301 _platforms = get_option('platforms')
302 if _platforms.contains('auto')
303 if system_has_kms_drm
304 _platforms = ['x11', 'wayland']
305 elif ['darwin', 'cygwin'].contains(host_machine.system())
307 elif ['haiku'].contains(host_machine.system())
308 _platforms = ['haiku']
309 elif host_machine.system() == 'windows'
310 _platforms = ['windows']
312 error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format(
313 host_machine.system()))
317 with_platform_android = _platforms.contains('android')
318 with_platform_x11 = _platforms.contains('x11')
319 with_platform_wayland = _platforms.contains('wayland')
320 with_platform_haiku = _platforms.contains('haiku')
321 with_platform_windows = _platforms.contains('windows')
323 with_glx = get_option('glx')
324 if with_glx == 'auto'
325 if with_platform_android
326 with_glx = 'disabled'
329 elif with_platform_haiku
330 with_glx = 'disabled'
331 elif host_machine.system() == 'windows'
332 with_glx = 'disabled'
334 # Even when building just gallium drivers the user probably wants dri
336 elif with_platform_x11 and with_any_opengl and not with_any_vk
337 # The automatic behavior should not be to turn on xlib based glx when
338 # building only vulkan drivers
341 with_glx = 'disabled'
350 if not (with_dri or with_gallium or with_glx != 'disabled')
354 with_any_opengl = false
355 with_shared_glapi = false
358 with_gbm = get_option('gbm') \
359 .require(system_has_kms_drm, error_message : 'GBM only supports DRM/KMS platforms') \
360 .disable_auto_if(not with_dri) \
363 with_xlib_lease = get_option('xlib-lease') \
364 .require(with_platform_x11 and system_has_kms_drm, error_message : 'xlib-lease requires X11 and KMS/DRM support') \
367 if with_platform_wayland
368 c_args += '-DVK_USE_PLATFORM_WAYLAND_KHR'
369 #add this once aco and other places can build with it
370 #cpp_args += '-DVK_USE_PLATFORM_WAYLAND_KHR'
373 c_args += ['-DVK_USE_PLATFORM_XCB_KHR', '-DVK_USE_PLATFORM_XLIB_KHR']
374 #add this once aco and other places can build with it
375 #cpp_args += ['-DVK_USE_PLATFORM_XCB_KHR', '-DVK_USE_PLATFORM_XLIB_KHR']
377 if with_platform_windows
378 c_args += '-DVK_USE_PLATFORM_WIN32_KHR'
379 cpp_args += '-DVK_USE_PLATFORM_WIN32_KHR'
381 if with_platform_android
382 c_args += '-DVK_USE_PLATFORM_ANDROID_KHR'
383 cpp_args += '-DVK_USE_PLATFORM_ANDROID_KHR'
386 c_args += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
387 #add this once aco and other places can build with it
388 #cpp_args += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
390 if system_has_kms_drm and not with_platform_android
391 c_args += '-DVK_USE_PLATFORM_DISPLAY_KHR'
392 cpp_args += '-DVK_USE_PLATFORM_DISPLAY_KHR'
394 if host_machine.system() == 'darwin'
395 c_args += '-DVK_USE_PLATFORM_MACOS_MVK'
396 cpp_args += '-DVK_USE_PLATFORM_MACOS_MVK'
397 c_args += '-DVK_USE_PLATFORM_METAL_EXT'
398 cpp_args += '-DVK_USE_PLATFORM_METAL_EXT'
401 with_egl = get_option('egl') \
402 .require(host_machine.system() != 'darwin', error_message : 'EGL not supported on MacOS') \
403 .require(with_platform_windows or with_platform_haiku or with_dri, error_message : 'EGL requires DRI, Haiku, or Windows') \
404 .require(with_shared_glapi, error_message : 'EGL requires shared-glapi') \
405 .require(with_glx != 'xlib', error_message :'EGL requires DRI, but GLX is being built with xlib support') \
406 .disable_auto_if(with_platform_haiku) \
410 _platforms += 'surfaceless'
411 if with_gbm and not with_platform_android
415 egl_native_platform = get_option('egl-native-platform')
416 if egl_native_platform.contains('auto')
417 egl_native_platform = _platforms[0]
421 if with_egl and not _platforms.contains(egl_native_platform)
422 error('-Degl-native-platform does not specify an enabled platform')
425 if 'x11' in _platforms
429 foreach platform : _platforms
430 pre_args += '-DHAVE_@0@_PLATFORM'.format(platform.to_upper())
433 if with_platform_android and get_option('platform-sdk-version') >= 29
434 # By default the NDK compiler, at least, emits emutls references instead of
435 # ELF TLS, even when building targeting newer API levels. Make it actually do
437 c_args += '-fno-emulated-tls'
438 cpp_args += '-fno-emulated-tls'
441 # -mtls-dialect=gnu2 speeds up non-initial-exec TLS significantly but requires
442 # full toolchain (including libc) support.
443 have_mtls_dialect = false
444 foreach c_arg : get_option('c_args')
445 if c_arg.startswith('-mtls-dialect=')
446 have_mtls_dialect = true
450 if not have_mtls_dialect
451 # need .run to check libc support. meson aborts when calling .run when
452 # cross-compiling, but because this is just an optimization we can skip it
453 if meson.is_cross_build() and not meson.can_run_host_binaries()
454 warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
456 # -fpic to force dynamic tls, otherwise TLS relaxation defeats check
457 gnu2_test = cc.run('int __thread x; int main() { return x; }',
458 args: ['-mtls-dialect=gnu2', '-fpic'],
459 name: '-mtls-dialect=gnu2')
460 if gnu2_test.returncode() == 0 and (
461 # check for lld 13 bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
462 host_machine.cpu_family() != 'x86_64' or
463 # get_linker_id misses LDFLAGS=-fuse-ld=lld: https://github.com/mesonbuild/meson/issues/6377
464 #cc.get_linker_id() != 'ld.lld' or
465 cc.links('''int __thread x; int y; int main() { __asm__(
466 "leaq x@TLSDESC(%rip), %rax\n"
467 "movq y@GOTPCREL(%rip), %rdx\n"
468 "call *x@TLSCALL(%rax)\n"); }''', name: 'split TLSDESC')
470 c_args += '-mtls-dialect=gnu2'
471 cpp_args += '-mtls-dialect=gnu2'
476 if with_glx != 'disabled'
477 if not (with_platform_x11 and with_any_opengl)
478 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
479 elif with_glx == 'xlib'
481 error('xlib based GLX requires at least one gallium driver')
482 elif not with_gallium_softpipe
483 error('xlib based GLX requires softpipe or llvmpipe.')
485 error('xlib conflicts with any dri driver')
487 elif with_glx == 'dri'
488 if not with_shared_glapi
489 error('dri based GLX requires shared-glapi')
494 with_glvnd = get_option('glvnd')
495 glvnd_vendor_name = get_option('glvnd-vendor-name')
497 if with_platform_windows
498 error('glvnd cannot be used on Windows')
499 elif with_glx == 'xlib'
500 error('Cannot build glvnd support for GLX that is not DRI based.')
501 elif with_glx == 'disabled' and not with_egl
502 error('glvnd requires DRI based GLX and/or EGL')
504 if get_option('egl-lib-suffix') != ''
505 error('''EGL lib suffix can't be used with libglvnd''')
509 if with_vulkan_icd_dir == ''
510 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
513 # GNU/Hurd includes egl_dri2, without drm.
514 with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or
515 host_machine.system() == 'gnu')
516 with_dri3 = get_option('dri3').disable_auto_if(not (system_has_kms_drm and with_dri2)).allowed()
518 if with_any_vk and (with_platform_x11 and not with_dri3)
519 error('Vulkan drivers require dri3 for X11 support')
522 if with_glx == 'disabled' and not with_egl and not with_gbm
523 error('building dri drivers require at least one windowing system')
527 if with_gallium_kmsro and (with_platform_x11 and not with_dri3)
528 error('kmsro requires dri3 for X11 support')
531 dep_dxheaders = null_dep
532 if with_gallium_d3d12 or with_microsoft_clc or with_microsoft_vk
533 dep_dxheaders = dependency('directx-headers', required : false)
534 if not dep_dxheaders.found()
535 dep_dxheaders = dependency('DirectX-Headers',
536 version : '>= 1.606.4',
537 fallback : ['DirectX-Headers', 'dep_dxheaders'],
538 required : with_gallium_d3d12 or with_microsoft_vk
543 _with_gallium_d3d12_video = get_option('gallium-d3d12-video')
544 with_gallium_d3d12_video = false
545 if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled()
546 with_gallium_d3d12_video = true
547 pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO'
551 with_gallium_d3d12_video,
552 with_gallium_nouveau,
555 with_gallium_radeonsi,
559 vdpau = get_option('gallium-vdpau') \
560 .require(system_has_kms_drm, error_message : 'VDPAU state tracker can only be build on unix-like OSes.') \
561 .require(with_platform_x11, error_message : 'VDPAU state tracker requires X11 support.') \
562 .require(_vdpau_drivers.contains(true), error_message : 'VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).')
564 dep_vdpau = dependency('vdpau', version : '>= 1.1', required : vdpau)
566 dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
567 pre_args += '-DHAVE_ST_VDPAU'
569 with_gallium_vdpau = dep_vdpau.found()
571 vdpau_drivers_path = get_option('vdpau-libs-path')
572 if vdpau_drivers_path == ''
573 vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
576 if with_vulkan_overlay_layer or with_aco_tests or with_amd_vk or with_intel_vk
577 prog_glslang = find_program('glslangValidator', native : true)
578 if run_command(prog_glslang, [ '--quiet', '--version' ], check : false).returncode() == 0
579 glslang_quiet = ['--quiet']
586 _omx = get_option('gallium-omx')
587 if not system_has_kms_drm
588 if ['auto', 'disabled'].contains(_omx)
591 error('OMX state tracker can only be built on unix-like OSes.')
593 elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
594 if ['auto', 'disabled'].contains(_omx)
597 error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
600 with_gallium_omx = _omx
603 if ['auto', 'bellagio'].contains(_omx)
604 dep_omx = dependency(
605 'libomxil-bellagio', required : _omx == 'bellagio'
608 with_gallium_omx = 'bellagio'
611 if ['auto', 'tizonia'].contains(_omx)
612 if with_dri and with_egl
613 dep_omx = dependency(
614 'libtizonia', version : '>= 0.10.0',
615 required : _omx == 'tizonia',
618 dependency('libtizplatform', required : _omx == 'tizonia'),
619 dependency('tizilheaders', required : _omx == 'tizonia'),
621 if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
622 with_gallium_omx = 'tizonia'
624 elif _omx == 'tizonia'
625 error('OMX-Tizonia state tracker requires dri and egl')
629 with_gallium_omx = 'disabled'
631 with_gallium_omx = _omx
635 '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'),
636 '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'),
640 omx_drivers_path = get_option('omx-libs-path')
642 if with_gallium_omx != 'disabled'
643 # Figure out where to put the omx driver.
644 # FIXME: this could all be vastly simplified by adding a 'defined_variable'
645 # argument to meson's get_variable method.
646 if omx_drivers_path == ''
647 _omx_libdir = dep_omx.get_variable(pkgconfig : 'libdir')
648 _omx_drivers_dir = dep_omx.get_variable(pkgconfig : 'pluginsdir')
649 if _omx_libdir == get_option('libdir')
650 omx_drivers_path = _omx_drivers_dir
653 # This will fail on windows. Does OMX run on windows?
654 _omx_libdir = _omx_libdir.split('/')
655 _omx_drivers_dir = _omx_drivers_dir.split('/')
656 foreach o : _omx_drivers_dir
657 if not _omx_libdir.contains(o)
661 omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
667 with_gallium_d3d12_video,
668 with_gallium_nouveau,
670 with_gallium_radeonsi,
674 _va = get_option('gallium-va') \
675 .require(_va_drivers.contains(true),
676 error_message : 'VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video), virgl.')
677 _dep_va_name = host_machine.system() == 'windows' ? 'libva-win32' : 'libva'
678 dep_va = dependency(_dep_va_name, version : '>= 1.8.0', required : _va)
680 dep_va_headers = dep_va.partial_dependency(compile_args : true)
681 if cc.has_header_symbol('va/va.h', 'VASurfaceAttribDRMFormatModifiers',
682 dependencies: dep_va_headers)
683 pre_args += '-DHAVE_VA_SURFACE_ATTRIB_DRM_FORMAT_MODIFIERS'
686 with_gallium_va = dep_va.found()
688 va_drivers_path = get_option('va-libs-path')
689 if va_drivers_path == ''
690 va_drivers_path = join_paths(get_option('libdir'), 'dri')
693 with_gallium_xa = get_option('gallium-xa') \
694 .require(system_has_kms_drm, error_message : 'XA state tracker can only be built on unix-like OSes.') \
695 .require(with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915 or with_gallium_svga,
696 error_message : 'XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.') \
699 d3d_drivers_path = get_option('d3d-drivers-path')
700 if d3d_drivers_path == ''
701 d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d')
704 with_gallium_st_nine = get_option('gallium-nine')
705 if with_gallium_st_nine
706 if not with_gallium_softpipe
707 error('The nine state tracker requires gallium softpipe/llvmpipe.')
710 with_gallium_freedreno,
713 with_gallium_nouveau,
714 with_gallium_panfrost,
717 with_gallium_radeonsi,
721 error('The nine state tracker requires at least one non-swrast gallium driver.')
724 error('Using nine with wine requires dri3')
727 with_gallium_st_d3d10umd = get_option('gallium-d3d10umd')
728 if with_gallium_st_d3d10umd
729 if not with_gallium_softpipe
730 error('The d3d10umd state tracker requires gallium softpipe/llvmpipe.')
733 _power8 = get_option('power8')
735 if host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little'
736 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
737 error('Altivec is not supported with gcc version < 4.8.')
742 vector unsigned char r;
743 vector unsigned int v = vec_splat_u32 (1);
744 r = __builtin_vec_vgbbd ((vector unsigned char) v);
747 args : '-mpower8-vector',
748 name : 'POWER8 intrinsics')
749 pre_args += ['-D_ARCH_PWR8', '-mpower8-vector']
750 elif _power8.enabled()
751 error('POWER8 intrinsic support required but not found.')
756 if get_option('vmware-mks-stats')
757 if not with_gallium_svga
758 error('vmware-mks-stats requires gallium VMware/svga driver.')
760 pre_args += '-DVMX86_STATS=1'
763 _opencl = get_option('gallium-opencl')
764 _rtti = get_option('cpp_rtti')
765 if _opencl != 'disabled'
767 error('OpenCL Clover implementation requires at least one gallium driver.')
770 error('The Clover OpenCL state tracker requires rtti')
774 with_gallium_opencl = true
775 with_opencl_icd = _opencl == 'icd'
777 with_gallium_opencl = false
778 with_opencl_icd = false
781 with_gallium_rusticl = get_option('gallium-rusticl')
782 if with_gallium_rusticl
784 error('rusticl requires at least one gallium driver.')
787 if meson.version().version_compare('< 0.61.4')
788 error('rusticl requires meson 0.61.4 or newer')
791 add_languages('rust', required: true)
799 dep_clc = dependency('libclc')
802 gl_pkgconfig_c_flags = []
804 if with_glx == 'xlib'
805 pre_args += '-DUSE_XSHM'
807 pre_args += '-DGLX_INDIRECT_RENDERING'
809 pre_args += '-DGLX_DIRECT_RENDERING'
811 if with_dri_platform == 'drm'
812 pre_args += '-DGLX_USE_DRM'
813 elif with_dri_platform == 'apple'
814 pre_args += '-DGLX_USE_APPLEGL'
815 elif with_dri_platform == 'windows'
816 pre_args += '-DGLX_USE_WINDOWSGL'
821 with_android_stub = get_option('android-stub')
822 if with_android_stub and not with_platform_android
823 error('`-D android-stub=true` makes no sense without `-D platforms=android`')
826 if with_platform_android
827 dep_android_mapper4 = null_dep
828 if not with_android_stub
830 dependency('cutils'),
831 dependency('hardware'),
833 dependency('backtrace')
835 if get_option('platform-sdk-version') >= 26
836 dep_android += dependency('nativewindow')
838 if get_option('platform-sdk-version') >= 30
839 dep_android_mapper4 = dependency('android.hardware.graphics.mapper', version : '>= 4.0', required : false)
844 '-DANDROID_API_LEVEL=' + get_option('platform-sdk-version').to_string()
848 prog_python = import('python').find_installation('python3')
849 has_mako = run_command(
852 from distutils.version import StrictVersion
854 assert StrictVersion(mako.__version__) > StrictVersion("0.8.0")
856 if has_mako.returncode() != 0
857 error('Python (3.x) mako module >= 0.8.0 required to build mesa.')
860 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
861 error('When using GCC, version 4.4.6 or later is required.')
864 # Support systems without ETIME (e.g. FreeBSD)
865 if cc.get_define('ETIME', prefix : '#include <errno.h>') == ''
866 pre_args += '-DETIME=ETIMEDOUT'
869 # Define DEBUG for debug builds only (debugoptimized is not included on this one)
870 if get_option('buildtype') == 'debug'
871 pre_args += '-DDEBUG'
874 with_shader_cache = get_option('shader-cache') \
875 .require(host_machine.system() != 'windows', error_message : 'Shader Cache does not currently work on Windows') \
879 pre_args += '-DENABLE_SHADER_CACHE'
880 if not get_option('shader-cache-default')
881 pre_args += '-DSHADER_CACHE_DISABLE_BY_DEFAULT'
884 shader_cache_max_size = get_option('shader-cache-max-size')
885 if shader_cache_max_size != ''
886 pre_args += '-DMESA_SHADER_CACHE_MAX_SIZE="@0@"'.format(shader_cache_max_size)
890 # Check for GCC style builtins
891 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
892 'ffsll', 'popcount', 'popcountll', 'unreachable', 'types_compatible_p']
893 if cc.has_function(b)
894 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
898 # check for GCC __attribute__
900 'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result',
901 'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn',
903 foreach a : cc.get_supported_function_attributes(_attributes)
904 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
906 if cc.has_function_attribute('visibility:hidden')
907 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
909 if cc.compiles('__uint128_t foo(void) { return 0; }',
910 name : '__uint128_t')
911 pre_args += '-DHAVE_UINT128'
914 if cc.has_function('reallocarray')
915 pre_args += '-DHAVE_REALLOCARRAY'
918 # TODO: this is very incomplete
919 if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku', 'android'].contains(host_machine.system())
920 pre_args += '-D_GNU_SOURCE'
921 elif host_machine.system() == 'sunos'
922 pre_args += '-D__EXTENSIONS__'
923 elif host_machine.system() == 'windows'
925 '-D_WINDOWS', '-D_WIN32_WINNT=0x0A00', '-DWINVER=0x0A00',
926 '-DPIPE_SUBSYSTEM_WINDOWS_USER',
927 '-D_USE_MATH_DEFINES', # XXX: scons didn't use this for mingw
929 if cc.get_argument_syntax() == 'msvc'
932 '-D_CRT_SECURE_NO_WARNINGS',
933 '-D_CRT_SECURE_NO_DEPRECATE',
934 '-D_SCL_SECURE_NO_WARNINGS',
935 '-D_SCL_SECURE_NO_DEPRECATE',
936 '-D_ALLOW_KEYWORD_MACROS',
937 '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
941 # When the target is not mingw/ucrt
942 # NOTE: clang's stddef.h are conflict with mingw/ucrt's stddef.h
943 # So do not include headers that defined in clang for detecting
947 #if defined(__MINGW32__) && defined(_UCRT)
950 int main(void) { return 0; }''')
951 pre_args += ['-D__MSVCRT_VERSION__=0x0700']
954 elif host_machine.system() == 'openbsd'
955 pre_args += '-D_ISOC11_SOURCE'
958 # Check for generic C arguments
959 c_msvc_compat_args = []
960 no_override_init_args = []
961 cpp_msvc_compat_args = []
962 if cc.get_argument_syntax() == 'msvc'
964 '/wd4018', # signed/unsigned mismatch
965 '/wd4056', # overflow in floating-point constant arithmetic
966 '/wd4244', # conversion from 'type1' to 'type2', possible loss of data
967 '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data
968 '/wd4305', # trancation from 'type1' to 'type2'
969 '/wd4351', # new behavior: elements of array 'array' will be default initialized
970 '/wd4756', # overflow in constant arithmetic
971 '/wd4800', # forcing value to bool 'true' or 'false' (performance warning)
972 '/wd4996', # disabled deprecated POSIX name warnings
973 '/wd4291', # no matching operator delete found
974 '/wd4146', # unary minus operator applied to unsigned type, result still unsigned
975 '/wd4200', # nonstandard extension used: zero-sized array in struct/union
976 '/wd4624', # destructor was implicitly defined as deleted [from LLVM]
977 '/wd4309', # 'initializing': truncation of constant value
978 '/wd4838', # conversion from 'int' to 'const char' requires a narrowing conversion
979 '/wd5105', # macro expansion producing 'defined' has undefined behavior (winbase.h, need Windows SDK upgrade)
980 '/we4020', # Error when passing the wrong number of parameters
981 '/we4024', # Error when passing different type of parameter
982 '/we4189', # 'identifier' : local variable is initialized but not referenced
983 '/Zc:__cplusplus', #Set __cplusplus macro to match the /std:c++<version> on the command line
985 c_args += cc.get_supported_arguments(_trial)
986 cpp_args += cpp.get_supported_arguments(_trial)
989 '-Werror=implicit-function-declaration',
990 '-Werror=missing-prototypes',
991 '-Werror=return-type',
992 '-Werror=empty-body',
993 '-Werror=incompatible-pointer-types',
994 '-Werror=int-conversion',
995 '-Wimplicit-fallthrough',
996 '-Wmisleading-indentation',
997 '-Wno-missing-field-initializers',
998 '-Wno-format-truncation',
1000 '-fno-trapping-math',
1001 '-Qunused-arguments',
1004 '-Wno-microsoft-enum-value',
1005 '-Wno-unused-function',
1008 '-Werror=return-type',
1009 '-Werror=empty-body',
1010 '-Wmisleading-indentation',
1011 '-Wno-non-virtual-dtor',
1012 '-Wno-missing-field-initializers',
1013 '-Wno-format-truncation',
1015 '-fno-trapping-math',
1016 '-Qunused-arguments',
1017 # Some classes use custom new operator which zeroes memory, however
1018 # gcc does aggressive dead-store elimination which threats all writes
1019 # to the memory before the constructor as "dead stores".
1020 # For now we disable this optimization.
1023 '-Wno-microsoft-enum-value',
1026 # MinGW chokes on format specifiers and I can't get it all working
1027 if not (cc.get_argument_syntax() == 'gcc' and host_machine.system() == 'windows')
1028 _trial_c += ['-Werror=format', '-Wformat-security']
1029 _trial_cpp += ['-Werror=format', '-Wformat-security']
1032 # FreeBSD annotated <pthread.h> but Mesa isn't ready
1033 if not (cc.get_id() == 'clang' and host_machine.system() == 'freebsd')
1034 _trial_c += ['-Werror=thread-safety']
1037 # If the compiler supports it, put function and data symbols in their
1038 # own sections and GC the sections after linking. This lets drivers
1039 # drop shared code unused by that specific driver (particularly
1040 # relevant for Vulkan drivers).
1041 if cc.has_link_argument('-Wl,--gc-sections')
1042 _trial_c += ['-ffunction-sections', '-fdata-sections']
1043 _trial_cpp += ['-ffunction-sections', '-fdata-sections']
1046 # Variables that are only used for assertions are considered unused in release
1047 # builds. Don't treat this as an error, since we build with -Werror even for
1049 if get_option('buildtype') == 'release'
1050 _trial_c += ['-Wno-unused-variable', '-Wno-unused-but-set-variable']
1051 _trial_cpp += ['-Wno-unused-variable', '-Wno-unused-but-set-variable']
1054 c_args += cc.get_supported_arguments(_trial_c)
1055 cpp_args += cpp.get_supported_arguments(_trial_cpp)
1057 no_override_init_args += cc.get_supported_arguments(
1058 ['-Wno-override-init', '-Wno-initializer-overrides']
1061 # Check for C and C++ arguments for MSVC compatibility. These are only used
1062 # in parts of the mesa code base that need to compile with MSVC, mainly
1064 _trial_msvc = ['-Werror=pointer-arith', '-Werror=vla', '-Werror=gnu-empty-initializer']
1065 c_msvc_compat_args += cc.get_supported_arguments(_trial_msvc)
1066 cpp_msvc_compat_args += cpp.get_supported_arguments(_trial_msvc)
1069 # set linker arguments
1070 if host_machine.system() == 'windows'
1071 if cc.get_argument_syntax() == 'msvc'
1072 add_project_link_arguments(
1076 language : ['c', 'cpp'],
1078 if get_option('buildtype') != 'debug'
1079 add_project_link_arguments(
1081 language : ['c', 'cpp'],
1085 add_project_link_arguments(
1086 cc.get_supported_link_arguments(
1088 '-Wl,--dynamicbase',
1090 '-static-libstdc++',
1094 add_project_link_arguments(
1095 cpp.get_supported_link_arguments(
1097 '-Wl,--dynamicbase',
1099 '-static-libstdc++',
1108 if host_machine.cpu_family().startswith('x86')
1109 pre_args += '-DUSE_SSE41'
1112 if cc.get_id() != 'msvc'
1113 sse41_args = ['-msse4.1']
1115 if host_machine.cpu_family() == 'x86'
1116 if get_option('sse2')
1117 # These settings make generated GCC code match MSVC and follow
1118 # GCC advice on https://gcc.gnu.org/wiki/FloatingPointMath#x86note
1120 # NOTE: We need to ensure stack is realigned given that we
1121 # produce shared objects, and have no control over the stack
1122 # alignment policy of the application. Therefore we need
1123 # -mstackrealign or -mincoming-stack-boundary=2.
1125 # XXX: We could have SSE without -mstackrealign if we always used
1126 # __attribute__((force_align_arg_pointer)), but that's not
1128 c_args += ['-msse2', '-mfpmath=sse', '-mstackrealign']
1130 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
1131 # that's not guaranteed
1132 sse41_args += '-mstackrealign'
1138 # Check for GCC style atomics
1139 dep_atomic = null_dep
1141 if cc.compiles('''#include <stdint.h>
1146 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1147 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1150 name : 'GCC atomic builtins')
1151 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
1153 # Not all atomic calls can be turned into lock-free instructions, in which
1154 # GCC will make calls into the libatomic library. Check whether we need to
1155 # link with -latomic.
1157 # This can happen for 64-bit atomic operations on 32-bit architectures such
1159 if not cc.links('''#include <stdint.h>
1164 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1165 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1167 name : 'GCC atomic builtins required -latomic')
1168 dep_atomic = cc.find_library('atomic')
1171 if not cc.links('''#include <stdint.h>
1174 return __sync_add_and_fetch(&v, (uint64_t)1);
1176 dependencies : dep_atomic,
1177 name : 'GCC 64bit atomics')
1178 pre_args += '-DMISSING_64BIT_ATOMICS'
1181 dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows)
1183 # TODO: shared/static? Is this even worth doing?
1186 if host_machine.cpu_family() == 'x86'
1187 if system_has_kms_drm or host_machine.system() == 'gnu'
1188 with_asm_arch = 'x86'
1189 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
1192 if with_glx_read_only_text
1193 pre_args += ['-DGLX_X86_READONLY_TEXT']
1196 elif host_machine.cpu_family() == 'x86_64'
1197 if system_has_kms_drm
1198 with_asm_arch = 'x86_64'
1199 pre_args += ['-DUSE_X86_64_ASM']
1201 elif host_machine.cpu_family() == 'arm'
1202 if system_has_kms_drm
1203 with_asm_arch = 'arm'
1204 pre_args += ['-DUSE_ARM_ASM']
1206 elif host_machine.cpu_family() == 'aarch64'
1207 if system_has_kms_drm
1208 with_asm_arch = 'aarch64'
1209 pre_args += ['-DUSE_AARCH64_ASM']
1211 elif host_machine.cpu_family() == 'sparc64'
1212 if system_has_kms_drm
1213 with_asm_arch = 'sparc'
1214 pre_args += ['-DUSE_SPARC_ASM']
1216 elif host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little'
1217 if system_has_kms_drm
1218 with_asm_arch = 'ppc64le'
1219 pre_args += ['-DUSE_PPC64LE_ASM']
1221 elif host_machine.cpu_family() == 'mips64' and host_machine.endian() == 'little'
1222 if system_has_kms_drm
1223 with_asm_arch = 'mips64el'
1224 pre_args += ['-DUSE_MIPS64EL_ASM']
1228 # Check for standard headers and functions
1229 if (cc.has_header_symbol('sys/sysmacros.h', 'major') and
1230 cc.has_header_symbol('sys/sysmacros.h', 'minor') and
1231 cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
1232 pre_args += '-DMAJOR_IN_SYSMACROS'
1234 if (cc.has_header_symbol('sys/mkdev.h', 'major') and
1235 cc.has_header_symbol('sys/mkdev.h', 'minor') and
1236 cc.has_header_symbol('sys/mkdev.h', 'makedev'))
1237 pre_args += '-DMAJOR_IN_MKDEV'
1240 if cc.check_header('sched.h')
1241 pre_args += '-DHAS_SCHED_H'
1242 if cc.has_function('sched_getaffinity')
1243 pre_args += '-DHAS_SCHED_GETAFFINITY'
1247 if not ['linux'].contains(host_machine.system())
1248 # Deprecated on Linux and requires <sys/types.h> on FreeBSD and OpenBSD
1249 if cc.check_header('sys/sysctl.h', prefix : '#include <sys/types.h>')
1250 pre_args += '-DHAVE_SYS_SYSCTL_H'
1254 foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h',
1255 'cet.h', 'pthread_np.h', 'renderdoc_app.h']
1256 if cc.check_header(h)
1257 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
1261 functions_to_detect = {
1264 'timespec_get': '#include <time.h>',
1273 foreach f, prefix: functions_to_detect
1274 if cc.has_function(f, prefix: prefix)
1275 pre_args += '-DHAVE_@0@'.format(f.to_upper())
1283 static int dcomp(const void *l, const void *r, void *t) { return 0; }
1285 int main(int ac, char **av) {
1288 qsort_r((void*)&arr[0], 1, 1, dcomp, t);
1292 name : 'GNU qsort_r')
1293 pre_args += '-DHAVE_GNU_QSORT_R'
1297 static int dcomp(void *t, const void *l, const void *r) { return 0; }
1299 int main(int ac, char **av) {
1302 qsort_r((void*)&arr[0], 1, 1, t, dcomp);
1306 name : 'BSD qsort_r')
1307 pre_args += '-DHAVE_BSD_QSORT_R'
1310 if cc.has_header_symbol('time.h', 'struct timespec')
1311 pre_args += '-DHAVE_STRUCT_TIMESPEC'
1314 with_c11_threads = false
1315 if cc.has_function('thrd_create', prefix: '#include <threads.h>')
1316 if with_platform_android
1317 # Current only Android's c11 <threads.h> are verified
1318 pre_args += '-DHAVE_THRD_CREATE'
1319 with_c11_threads = true
1323 if cc.has_header_symbol('errno.h', 'program_invocation_name',
1324 args : '-D_GNU_SOURCE')
1325 pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'
1326 elif with_tools.contains('intel')
1327 error('Intel tools require the program_invocation_name variable')
1330 if cc.has_header_symbol('math.h', 'issignaling',
1331 args : '-D_GNU_SOURCE')
1332 pre_args += '-DHAVE_ISSIGNALING'
1335 # MinGW provides a __builtin_posix_memalign function, but not a posix_memalign.
1336 # This means that this check will succeed, but then compilation will later
1337 # fail. MSVC doesn't have this function at all, so only check for it on
1338 # non-windows platforms.
1339 if host_machine.system() != 'windows'
1340 if cc.has_function('posix_memalign')
1341 pre_args += '-DHAVE_POSIX_MEMALIGN'
1345 if cc.has_member('struct dirent', 'd_type', prefix: '''#include <sys/types.h>
1346 #include <dirent.h>''')
1347 pre_args += '-DHAVE_DIRENT_D_TYPE'
1350 # strtod locale support
1355 #ifdef HAVE_XLOCALE_H
1356 #include <xlocale.h>
1359 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
1360 const char *s = "1.0";
1362 double d = strtod_l(s, end, loc);
1363 float f = strtof_l(s, end, loc);
1368 name : 'strtod has locale support')
1369 pre_args += '-DHAVE_STRTOD_L'
1372 # Check for some linker flags
1373 ld_args_bsymbolic = []
1374 if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
1375 ld_args_bsymbolic += '-Wl,-Bsymbolic'
1377 ld_args_gc_sections = []
1378 if cc.links('static char unused() { return 5; } int main() { return 0; }',
1379 args : '-Wl,--gc-sections', name : 'gc-sections')
1380 ld_args_gc_sections += '-Wl,--gc-sections'
1382 with_ld_version_script = false
1383 if cc.links('int main() { return 0; }',
1384 args : '-Wl,--version-script=@0@'.format(
1385 join_paths(meson.current_source_dir(), 'build-support/conftest.map')),
1386 name : 'version-script')
1387 with_ld_version_script = true
1389 with_ld_dynamic_list = false
1390 if cc.links('int main() { return 0; }',
1391 args : '-Wl,--dynamic-list=@0@'.format(
1392 join_paths(meson.current_source_dir(), 'build-support/conftest.dyn')),
1393 name : 'dynamic-list')
1394 with_ld_dynamic_list = true
1397 ld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1')
1399 # check for dl support
1401 if host_machine.system() != 'windows'
1402 if not cc.has_function('dlopen')
1403 dep_dl = cc.find_library('dl', required : true)
1405 if cc.has_function('dladdr', dependencies : dep_dl)
1406 # This is really only required for util/disk_cache.h
1407 pre_args += '-DHAVE_DLADDR'
1411 if cc.has_function('dl_iterate_phdr')
1412 pre_args += '-DHAVE_DL_ITERATE_PHDR'
1413 elif with_intel_vk or with_intel_hasvk
1414 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
1417 # only used in Iris and ANV
1418 if with_any_intel and ['x86', 'x86_64'].contains(host_machine.cpu_family())
1419 pre_args += '-DSUPPORT_INTEL_INTEGRATED_GPUS'
1422 # Determine whether or not the rt library is needed for time functions
1423 if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
1424 dep_clock = null_dep
1426 dep_clock = cc.find_library('rt')
1429 dep_zlib = dependency('zlib', version : '>= 1.2.3',
1430 fallback : ['zlib', 'zlib_dep'],
1431 required : get_option('zlib'))
1433 pre_args += '-DHAVE_ZLIB'
1436 dep_zstd = dependency('libzstd', required : get_option('zstd'))
1438 pre_args += '-DHAVE_ZSTD'
1441 with_compression = dep_zlib.found() or dep_zstd.found()
1443 pre_args += '-DHAVE_COMPRESSION'
1444 elif with_shader_cache
1445 error('Shader Cache requires compression')
1448 if host_machine.system() == 'windows'
1449 # For MSVC and MinGW we aren't using pthreads, and dependency('threads') will add linkage
1450 # to pthread for MinGW, so leave the dependency null_dep for Windows. For Windows linking to
1451 # kernel32 is enough for c11/threads.h and it's already linked by meson by default
1452 dep_thread = null_dep
1454 dep_thread = dependency('threads')
1456 if dep_thread.found()
1457 pre_args += '-DHAVE_PTHREAD'
1458 if host_machine.system() != 'netbsd' and cc.has_function(
1459 'pthread_setaffinity_np',
1460 dependencies : dep_thread,
1461 prefix : '#include <pthread.h>',
1462 args : '-D_GNU_SOURCE')
1463 pre_args += '-DHAVE_PTHREAD_SETAFFINITY'
1467 # We don't have expat on Android or Windows, which is a needed dep for xmlconfig
1468 opt_xmlconfig = get_option('xmlconfig') \
1469 .require(not (with_platform_android or with_platform_windows),
1470 error_message : 'xmlconfig not available on Android or Windows')
1472 if host_machine.system() == 'darwin'
1473 dep_expat = meson.get_compiler('c').find_library('expat', required : opt_xmlconfig)
1475 dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'],
1476 required : opt_xmlconfig)
1478 use_xmlconfig = dep_expat.found()
1480 # Predefined macros for windows
1481 if host_machine.system() == 'windows'
1482 pre_args += '-DWIN32_LEAN_AND_MEAN' # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx
1484 # this only exists on linux so either this is linux and it will be found, or
1485 # it's not linux and wont
1486 dep_m = cc.find_library('m', required : false)
1488 if host_machine.system() == 'windows'
1489 dep_regex = meson.get_compiler('c').find_library('regex', required : false)
1490 if not dep_regex.found()
1491 dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
1494 dep_regex = null_dep
1497 if with_platform_haiku
1498 dep_network = cc.find_library('network')
1501 dep_futex = null_dep
1502 if host_machine.system() == 'windows'
1503 if (get_option('min-windows-version') < 8)
1504 pre_args += '-DWINDOWS_NO_FUTEX'
1506 dep_futex = cc.find_library('synchronization', required : true)
1510 # Check for libdrm. Various drivers have different libdrm version requirements,
1511 # but we always want to use the same version for all libdrm modules. That means
1512 # even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and
1513 # bar are both on use 2.4.3 for both of them
1514 dep_libdrm_amdgpu = null_dep
1515 dep_libdrm_radeon = null_dep
1516 dep_libdrm_nouveau = null_dep
1517 dep_libdrm_intel = null_dep
1519 _drm_amdgpu_ver = '2.4.110'
1520 _drm_radeon_ver = '2.4.71'
1521 _drm_nouveau_ver = '2.4.102'
1522 _drm_intel_ver = '2.4.75'
1523 _drm_ver = '2.4.109'
1526 ['intel', with_gallium_i915],
1527 ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi],
1528 ['radeon', (with_gallium_radeonsi or with_gallium_r300 or with_gallium_r600)],
1529 ['nouveau', with_gallium_nouveau],
1532 # Loop over the enables versions and get the highest libdrm requirement for all
1535 foreach d : _libdrm_checks
1536 ver = get_variable('_drm_@0@_ver'.format(d[0]))
1537 if d[1] and ver.version_compare('>' + _drm_ver)
1543 message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame))
1546 # Then get each libdrm module
1547 foreach d : _libdrm_checks
1550 'dep_libdrm_' + d[0],
1551 dependency('libdrm_' + d[0], version : '>=' + _drm_ver)
1556 with_gallium_drisw_kms = false
1557 dep_libdrm = dependency(
1558 'libdrm', version : '>=' + _drm_ver,
1559 # GNU/Hurd includes egl_dri2, without drm.
1560 required : (with_dri2 and host_machine.system() != 'gnu') or with_dri3
1562 if dep_libdrm.found()
1563 pre_args += '-DHAVE_LIBDRM'
1564 if with_dri_platform == 'drm' and with_dri
1565 with_gallium_drisw_kms = true
1569 dep_libudev = dependency('libudev', required : false)
1570 if dep_libudev.found()
1571 pre_args += '-DHAVE_LIBUDEV'
1574 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit', 'core', 'executionengine', 'scalaropts', 'transformutils', 'instcombine']
1575 llvm_optional_modules = ['coroutines']
1576 if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
1577 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
1578 if with_gallium_r600
1579 llvm_modules += 'asmparser'
1582 if with_gallium_opencl
1584 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
1585 'lto', 'option', 'objcarcopts', 'profiledata'
1587 # all-targets is needed to support static linking LLVM build with multiple targets
1588 # windowsdriver is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet
1589 llvm_optional_modules += ['all-targets', 'frontendopenmp', 'windowsdriver']
1592 llvm_modules += ['coverage', 'target', 'linker', 'irreader', 'option', 'libdriver', 'lto']
1593 # all-targets is needed to support static linking LLVM build with multiple targets
1594 # windowsdriver is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet
1595 llvm_optional_modules += ['all-targets', 'windowsdriver']
1597 draw_with_llvm = get_option('draw-use-llvm')
1599 llvm_modules += 'native'
1600 # lto is needded with LLVM>=15, but we don't know what LLVM verrsion we are using yet
1601 llvm_optional_modules += ['lto']
1605 _llvm_version = '>= 13.0.0'
1606 elif with_amd_vk or with_gallium_radeonsi or with_gallium_opencl
1607 _llvm_version = '>= 11.0.0'
1609 _llvm_version = '>= 10.0.0'
1611 _llvm_version = '>= 5.0.0'
1614 _shared_llvm = get_option('shared-llvm') \
1615 .disable_auto_if(host_machine.system() == 'windows') \
1618 _llvm = get_option('llvm')
1622 dep_llvm = dependency(
1624 version : _llvm_version,
1625 modules : llvm_modules,
1626 optional_modules : llvm_optional_modules,
1628 with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or with_clc
1631 static : not _shared_llvm,
1632 fallback : ['llvm', 'dep_llvm'],
1633 include_type : 'system',
1635 with_llvm = dep_llvm.found()
1638 pre_args += '-DLLVM_AVAILABLE'
1639 pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version())
1640 pre_args += '-DLLVM_IS_SHARED=@0@'.format(_shared_llvm.to_int())
1643 pre_args += '-DDRAW_LLVM_AVAILABLE'
1645 error('Lavapipe requires LLVM draw support.')
1648 if host_machine.system() != 'windows'
1649 # LLVM can be built without rtti, turning off rtti changes the ABI of C++
1650 # programs, so we need to build all C++ code in mesa without rtti as well to
1651 # ensure that linking works. Note that Win32 compilers does handle mismatching RTTI
1652 # without issues, so only apply this for other compilers.
1653 if dep_llvm.type_name() == 'internal'
1654 _llvm_rtti = subproject('llvm').get_variable('has_rtti', true)
1656 # The CMake finder will return 'ON', the llvm-config will return 'YES'
1657 _llvm_rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
1659 if _rtti != _llvm_rtti
1661 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.')
1663 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.')
1668 if cc.get_argument_syntax() == 'msvc'
1669 # Suppress "/DELAYLOAD:ole32.dll/shell32.dll ignored" warnings that LLVM adds
1670 add_project_link_arguments(
1672 language : ['c', 'cpp'],
1675 elif with_amd_vk and with_aco_tests
1676 error('ACO tests require LLVM, but LLVM is disabled.')
1677 elif with_gallium_radeonsi or with_swrast_vk
1678 error('The following drivers require LLVM: RadeonSI, SWR, Lavapipe. One of these is enabled, but LLVM is disabled.')
1679 elif with_gallium_opencl
1680 error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
1682 error('The CLC compiler requires LLVM, but LLVM is disabled.')
1684 draw_with_llvm = false
1687 with_opencl_spirv = (_opencl != 'disabled' and get_option('opencl-spirv')) or with_clc
1688 if with_opencl_spirv
1689 chosen_llvm_version_array = dep_llvm.version().split('.')
1690 chosen_llvm_version_major = chosen_llvm_version_array[0].to_int()
1691 chosen_llvm_version_minor = chosen_llvm_version_array[1].to_int()
1693 # Require an SPIRV-LLVM-Translator version compatible with the chosen LLVM
1696 # This first version check is still needed as maybe LLVM 8.0 was picked but
1697 # we do not want to accept SPIRV-LLVM-Translator 8.0.0.1 as that version
1698 # does not have the required API and those are only available starting from
1700 _llvmspirvlib_min_version = '>= 8.0.1.3'
1702 _llvmspirvlib_min_version = '>= 13.0.0.0'
1705 _llvmspirvlib_version = [
1706 _llvmspirvlib_min_version,
1707 '>= @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor),
1708 '< @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor + 1) ]
1710 dep_spirv_tools = dependency('SPIRV-Tools', required : true, version : '>= 2018.0')
1711 # LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator
1712 dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : _llvmspirvlib_version)
1714 dep_spirv_tools = null_dep
1715 dep_llvmspirvlib = null_dep
1718 dep_clang = null_dep
1720 llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
1722 dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
1724 if not dep_clang.found() or not _shared_llvm
1726 'clangBasic', 'clangAST', 'clangCodeGen', 'clangLex',
1727 'clangDriver', 'clangFrontend', 'clangFrontendTool',
1728 'clangHandleCXX', 'clangHandleLLVM', 'clangSerialization',
1729 'clangSema', 'clangParse', 'clangEdit', 'clangAnalysis'
1731 if dep_llvm.version().version_compare('>= 15.0')
1732 clang_modules += 'clangSupport'
1736 foreach m : clang_modules
1737 dep_clang += cpp.find_library(m, dirs : llvm_libdir, required : true)
1742 # Be explicit about only using this lib on Windows, to avoid picking
1743 # up random libs with the generic name 'libversion'
1744 dep_version = null_dep
1745 if host_machine.system() == 'windows'
1746 dep_version = cpp.find_library('version')
1749 dep_elf = dependency('libelf', required : false)
1750 if not with_platform_windows and not dep_elf.found()
1751 dep_elf = cc.find_library('elf', required : false)
1754 pre_args += '-DUSE_LIBELF'
1757 dep_glvnd = null_dep
1759 dep_glvnd = dependency('libglvnd', version : '>= 1.3.2')
1760 pre_args += '-DUSE_LIBGLVND=1'
1763 dep_valgrind = dependency('valgrind', required : get_option('valgrind'))
1764 if dep_valgrind.found()
1765 pre_args += '-DHAVE_VALGRIND'
1768 # AddressSanitizer's leak reports need all the symbols to be present at exit to
1769 # decode well, which runs afoul of our dlopen()/dlclose()ing of the DRI drivers.
1770 # Set a flag so we can skip the dlclose for asan builds.
1771 if ['address', 'address,undefined'].contains(get_option('b_sanitize'))
1772 asan_c_args = ['-DBUILT_WITH_ASAN=1']
1774 asan_c_args = ['-DBUILT_WITH_ASAN=0']
1777 yacc_is_bison = true
1779 if build_machine.system() == 'windows'
1780 # Prefer the winflexbison versions, they're much easier to install and have
1781 # better windows support.
1783 prog_flex = find_program('win_flex', required : false)
1784 if prog_flex.found()
1785 # windows compatibility (uses <io.h> instead of <unistd.h> and _isatty,
1786 # _fileno functions)
1787 prog_flex = [prog_flex, '--wincompat']
1789 prog_flex = [find_program('flex', 'lex', required : with_any_opengl, disabler : true)]
1791 # Force flex to use const keyword in prototypes, as relies on __cplusplus or
1792 # __STDC__ macro to determine whether it's safe to use const keyword
1793 prog_flex += '-DYY_USE_CONST='
1795 prog_flex_cpp = prog_flex
1796 # Convince win_flex to use <inttypes.h> for C++ files
1797 # Note that we are using a C99 version here rather than C11,
1798 # because using a C11 version can cause the MSVC CRT headers to define
1799 # static_assert to _Static_assert, which breaks other parts of the CRT
1800 prog_flex_cpp += '-D__STDC_VERSION__=199901'
1802 prog_bison = find_program('win_bison', required : false)
1803 if not prog_bison.found()
1804 prog_bison = find_program('bison', 'yacc', required : with_any_opengl, disabler : true)
1807 prog_bison = find_program('bison', required : false)
1809 if not prog_bison.found()
1810 prog_bison = find_program('byacc', required : with_any_opengl, disabler : true)
1811 yacc_is_bison = false
1814 # Disable deprecated keyword warnings, since we have to use them for
1815 # old-bison compat. See discussion in
1816 # https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2161
1817 if find_program('bison', required : false, version : '> 2.3').found()
1818 prog_bison = [prog_bison, '-Wno-deprecated']
1821 prog_flex = find_program('flex', required : with_any_opengl, disabler : true)
1822 prog_flex_cpp = prog_flex
1825 dep_selinux = null_dep
1826 if get_option('selinux')
1827 if get_option('execmem') != true
1828 warning('execmem option is disabled, selinux will not be able to use execmem.')
1830 dep_selinux = dependency('libselinux')
1831 pre_args += '-DMESA_SELINUX'
1834 if get_option('execmem')
1835 pre_args += '-DMESA_EXECMEM'
1838 _libunwind = get_option('libunwind') \
1839 .require(not with_platform_android, error_message : 'Android requires the use of the backtrace library, not libunwind')
1840 if host_machine.system() == 'darwin'
1841 dep_unwind = meson.get_compiler('c').find_library('System', required : _libunwind)
1843 dep_unwind = dependency('libunwind', required : _libunwind)
1845 if dep_unwind.found()
1846 pre_args += '-DHAVE_LIBUNWIND'
1850 if not with_gallium_softpipe
1851 error('OSMesa gallium requires gallium softpipe or llvmpipe.')
1853 if host_machine.system() == 'windows'
1854 osmesa_lib_name = 'osmesa'
1856 osmesa_lib_name = 'OSMesa'
1858 osmesa_bits = get_option('osmesa-bits')
1859 if osmesa_bits != 'unspecified'
1860 warning('osmesa-bits option is deprecated and have no effect, please remove it.')
1864 # TODO: symbol mangling
1866 if with_platform_wayland
1867 dep_wl_scanner = dependency('wayland-scanner', native: true)
1868 prog_wl_scanner = find_program(dep_wl_scanner.get_variable(pkgconfig : 'wayland_scanner'))
1869 if dep_wl_scanner.version().version_compare('>= 1.15')
1870 wl_scanner_arg = 'private-code'
1872 wl_scanner_arg = 'code'
1874 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.24')
1875 dep_wayland_client = dependency('wayland-client', version : '>=1.18')
1876 dep_wayland_server = dependency('wayland-server', version : '>=1.18')
1878 dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3')
1879 dep_wayland_egl_headers = dep_wayland_egl.partial_dependency(compile_args : true)
1881 wayland_dmabuf_xml = join_paths(
1882 dep_wl_protocols.get_variable(pkgconfig : 'pkgdatadir'), 'unstable',
1883 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
1885 pre_args += '-DWL_HIDE_DEPRECATED'
1890 dep_xfixes = null_dep
1891 dep_x11_xcb = null_dep
1893 dep_xcb_glx = null_dep
1894 dep_xcb_dri2 = null_dep
1895 dep_xcb_dri3 = null_dep
1896 dep_dri2proto = null_dep
1897 dep_glproto = null_dep
1898 dep_xxf86vm = null_dep
1899 dep_xcb_dri3 = null_dep
1900 dep_xcb_present = null_dep
1901 dep_xcb_sync = null_dep
1902 dep_xcb_xfixes = null_dep
1903 dep_xshmfence = null_dep
1904 dep_xcb_xrandr = null_dep
1905 dep_xcb_shm = null_dep
1906 dep_xlib_xrandr = null_dep
1907 dep_openmp = null_dep
1909 # Even if we find OpenMP, Gitlab CI fails to link with gcc/i386 and clang/anyarch.
1910 if host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc'
1911 dep_openmp = dependency('openmp', required : false)
1912 if dep_openmp.found()
1913 pre_args += ['-DHAVE_OPENMP']
1917 with_dri3_modifiers = false
1918 if with_platform_x11
1919 if with_glx == 'xlib'
1920 dep_x11 = dependency('x11')
1921 dep_xext = dependency('xext')
1922 dep_xcb = dependency('xcb')
1923 dep_xcb_xrandr = dependency('xcb-randr')
1924 elif with_glx == 'dri'
1925 dep_x11 = dependency('x11')
1926 dep_xext = dependency('xext')
1927 dep_xfixes = dependency('xfixes', version : '>= 2.0')
1928 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
1929 dep_xcb_shm = dependency('xcb-shm')
1931 if (with_any_vk or with_glx == 'dri' or with_egl or
1932 (with_gallium_vdpau or with_gallium_va or
1933 with_gallium_omx != 'disabled'))
1934 dep_xcb = dependency('xcb')
1935 dep_x11_xcb = dependency('x11-xcb')
1936 if with_dri_platform == 'drm' and not dep_libdrm.found()
1937 error('libdrm required for gallium video statetrackers when using x11')
1940 if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
1941 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
1944 dep_xcb_dri3 = dependency('xcb-dri3')
1945 dep_xcb_present = dependency('xcb-present')
1946 # until xcb-dri3 has been around long enough to make a hard-dependency:
1947 if (dep_xcb_dri3.version().version_compare('>= 1.13') and
1948 dep_xcb_present.version().version_compare('>= 1.13'))
1949 with_dri3_modifiers = true
1951 dep_xcb_shm = dependency('xcb-shm')
1952 dep_xcb_sync = dependency('xcb-sync')
1953 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
1956 if with_glx == 'dri' or with_glx == 'xlib'
1957 dep_glproto = dependency('glproto', version : '>= 1.4.14')
1959 if with_glx == 'dri'
1960 if with_dri_platform == 'drm'
1961 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
1963 dep_xxf86vm = dependency('xxf86vm')
1969 with_gallium_vdpau or with_gallium_xa or
1970 with_gallium_omx != 'disabled'))
1971 dep_xcb_xfixes = dependency('xcb-xfixes')
1973 if with_xlib_lease or with_any_vk
1974 dep_xcb_xrandr = dependency('xcb-randr')
1977 dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
1982 pre_args += '-DHAVE_DRI'
1985 pre_args += '-DHAVE_DRI2'
1988 pre_args += '-DHAVE_DRI3'
1990 if with_dri3_modifiers
1991 pre_args += '-DHAVE_DRI3_MODIFIERS'
1993 if with_gallium_drisw_kms
1994 pre_args += '-DHAVE_DRISW_KMS'
1997 if get_option('gallium-extra-hud')
1998 pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
2001 dep_lmsensors = cc.find_library('sensors', required : get_option('lmsensors'))
2002 if dep_lmsensors.found()
2003 pre_args += '-DHAVE_LIBSENSORS=1'
2006 _shader_replacement = get_option('custom-shader-replacement')
2007 if _shader_replacement == ''
2009 pre_args += '-DCUSTOM_SHADER_REPLACEMENT'
2012 with_perfetto = get_option('perfetto')
2013 with_datasources = get_option('datasources')
2014 with_any_datasource = with_datasources.length() != 0
2016 dep_perfetto = dependency('perfetto', fallback: ['perfetto', 'dep_perfetto'])
2017 pre_args += '-DHAVE_PERFETTO'
2020 add_project_arguments(pre_args, language : ['c', 'cpp'])
2021 add_project_arguments(c_args, language : ['c'])
2022 add_project_arguments(cpp_args, language : ['cpp'])
2026 if with_glx == 'xlib'
2027 gl_priv_reqs += ['x11', 'xext', 'xcb']
2028 elif with_glx == 'dri'
2030 'x11', 'xext', 'xfixes', 'x11-xcb', 'xcb',
2032 if with_dri_platform == 'drm'
2033 gl_priv_reqs += 'xcb-dri2 >= 1.8'
2035 gl_priv_reqs += 'xxf86vm'
2039 if dep_libdrm.found()
2040 gl_priv_reqs += 'libdrm >= 2.4.75'
2044 if dep_thread.found()
2045 gl_priv_libs += ['-lpthread', '-pthread']
2048 gl_priv_libs += '-lm'
2051 gl_priv_libs += '-ldl'
2054 # FIXME: autotools lists this as incomplete
2057 gbm_priv_libs += '-ldl'
2060 pkg = import('pkgconfig')
2062 if host_machine.system() == 'windows'
2063 prog_dumpbin = find_program('dumpbin', required : false)
2064 with_symbols_check = prog_dumpbin.found() and with_tests
2065 if with_symbols_check
2066 symbols_check_args = ['--dumpbin', prog_dumpbin.full_path()]
2069 prog_nm = find_program('nm')
2070 with_symbols_check = with_tests
2071 symbols_check_args = ['--nm', prog_nm.full_path()]
2074 # This quirk needs to be applied to sources with functions defined in assembly
2075 # as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391
2076 gcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : []
2078 devenv = environment()
2080 dir_compiler_nir = join_paths(meson.current_source_dir(), 'src/compiler/nir/')
2081 dir_source_root = meson.project_source_root()
2088 meson.add_devenv(devenv)
2090 meson.add_devenv(devenv)
2094 'prefix': get_option('prefix'),
2095 'libdir': get_option('libdir'),
2096 'includedir': get_option('includedir'),
2098 section: 'Directories'
2103 'OpenGL': with_opengl,
2106 'Shared glapi': with_shared_glapi,
2108 section: 'OpenGL', bool_yn: true
2113 'Platform': with_dri_platform,
2114 'Driver dir': dri_drivers_path,
2116 section: 'DRI', bool_yn: true, list_sep: ' '
2121 'Enabled': with_glx != 'disabled',
2122 'Provider': with_glx == 'disabled' ? 'None' : with_glx
2124 section: 'GLX', bool_yn: true, list_sep: ' '
2127 egl_summary = {'Enabled': with_egl}
2131 egl_drivers += 'builtin:egl_dri2'
2134 egl_drivers += 'builtin:egl_dri3'
2136 if with_platform_windows
2137 egl_drivers += 'builtin:wgl'
2139 egl_summary += {'Drivers': egl_drivers}
2140 egl_summary += {'Platforms': _platforms}
2142 summary(egl_summary, section: 'EGL', bool_yn: true, list_sep: ' ')
2144 gbm_summary = {'Enabled': with_gbm}
2146 gbm_summary += {'Backends path': gbm_backends_path}
2148 summary(gbm_summary, section: 'GBM', bool_yn: true, list_sep: ' ')
2150 vulkan_summary = {'Drivers': _vulkan_drivers.length() != 0 ? _vulkan_drivers : false }
2152 vulkan_summary += {'Platforms': _platforms}
2153 vulkan_summary += {'ICD dir': with_vulkan_icd_dir}
2154 if with_any_vulkan_layers
2155 vulkan_summary += {'Layers': get_option('vulkan-layers')}
2157 vulkan_summary += {'Video codecs': _codecs.length() != 0 ? _codecs : false}
2158 vulkan_summary += {'Ray tracing': with_intel_vk_rt ? 'intel' : false}
2160 summary(vulkan_summary, section: 'Vulkan', bool_yn: true, list_sep: ' ')
2162 llvm_summary = {'Enabled': with_llvm}
2164 llvm_summary += {'Version': dep_llvm.version()}
2166 summary(llvm_summary, section: 'LLVM', bool_yn: true, list_sep: ' ')
2168 gallium_summary = {'Enabled': with_gallium}
2170 gallium_summary += {'Drivers': gallium_drivers}
2171 gallium_summary += {'Platforms': _platforms}
2173 gallium_frontends = ['mesa']
2175 gallium_frontends += 'xa'
2177 if with_gallium_vdpau
2178 gallium_frontends += 'vdpau'
2180 if with_gallium_omx != 'disabled'
2181 gallium_frontends += 'omx' + with_gallium_omx
2184 gallium_frontends += 'va'
2186 if with_gallium_st_nine
2187 gallium_frontends += 'nine'
2189 if with_gallium_opencl
2190 gallium_frontends += 'clover'
2192 if with_gallium_rusticl
2193 gallium_frontends += 'rusticl'
2195 gallium_summary += {'Frontends': gallium_frontends}
2196 gallium_summary += {'Off-screen rendering': with_osmesa ? 'lib' + osmesa_lib_name : false}
2197 gallium_summary += {'HUD lm-sensors': dep_lmsensors.found()}
2199 summary(gallium_summary, section: 'Gallium', bool_yn: true, list_sep: ' ')
2201 perfetto_summary = {'Enabled': with_perfetto}
2202 if with_perfetto and with_any_datasource
2203 perfetto_summary += {'Data source': with_datasources}
2205 summary(perfetto_summary, section: 'Perfetto', bool_yn: true, list_sep: ' ')