meson: deprecated 'true' and 'false' in combo options for 'enabled' and 'disabled'
[mesa.git] / meson.build
1 # Copyright © 2017-2020 Intel Corporation
2
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:
9
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12
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
19 # SOFTWARE.
20
21 project(
22 'mesa',
23 ['c', 'cpp'],
24 version : run_command(
25 [find_program('python', 'python3'), 'bin/meson_get_version.py']
26 ).stdout(),
27 license : 'MIT',
28 meson_version : '>= 0.52',
29 default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c99', 'cpp_std=c++14']
30 )
31
32 cc = meson.get_compiler('c')
33 cpp = meson.get_compiler('cpp')
34
35 null_dep = dependency('', required : false)
36
37 if get_option('layout') != 'mirror'
38 error('`mirror` is the only build directory layout supported')
39 endif
40
41 # Arguments for the preprocessor, put these in a separate array from the C and
42 # C++ (cpp in meson terminology) arguments since they need to be added to the
43 # default arguments for both C and C++.
44 pre_args = [
45 '-D__STDC_CONSTANT_MACROS',
46 '-D__STDC_FORMAT_MACROS',
47 '-D__STDC_LIMIT_MACROS',
48 '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
49 '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/-/issues"',
50 ]
51
52 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
53 with_tests = get_option('build-tests')
54 with_glx_read_only_text = get_option('glx-read-only-text')
55 with_glx_direct = get_option('glx-direct')
56 with_osmesa = get_option('osmesa')
57 with_swr_arches = get_option('swr-arches')
58 with_vulkan_overlay_layer = get_option('vulkan-overlay-layer')
59 with_tools = get_option('tools')
60 if with_tools.contains('all')
61 with_tools = [
62 'drm-shim',
63 'etnaviv',
64 'freedreno',
65 'glsl',
66 'intel',
67 'intel-ui',
68 'lima',
69 'nir',
70 'nouveau',
71 'xvmc',
72 ]
73 endif
74
75 with_intel_tools = with_tools.contains('intel') or with_tools.contains('intel-ui')
76 with_imgui = with_intel_tools or with_vulkan_overlay_layer
77
78 dri_drivers_path = get_option('dri-drivers-path')
79 if dri_drivers_path == ''
80 dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
81 endif
82 dri_search_path = get_option('dri-search-path')
83 if dri_search_path == ''
84 dri_search_path = dri_drivers_path
85 endif
86
87 with_gles1 = get_option('gles1')
88 if with_gles1 == 'true'
89 with_gles1 = 'enabled'
90 warning('gles1 option "true" deprecated, please use "enabled" instead.')
91 elif with_gles1 == 'false'
92 with_gles1 = 'disabled'
93 warning('gles1 option "false" deprecated, please use "disabled" instead.')
94 endif
95 with_gles2 = get_option('gles2')
96 if with_gles2 == 'true'
97 with_gles2 = 'enabled'
98 warning('gles2 option "true" deprecated, please use "enabled" instead.')
99 elif with_gles2 == 'false'
100 with_gles2 = 'disabled'
101 warning('gles2 option "false" deprecated, please use "disabled" instead.')
102 endif
103 if host_machine.system() == 'windows'
104 if with_gles1 == 'auto'
105 with_gles1 = 'disabled'
106 endif
107 if with_gles2 == 'auto'
108 with_gles2 = 'disabled'
109 endif
110 endif
111 with_opengl = get_option('opengl')
112
113 # Default shared glapi off for windows, on elsewhere.
114 _sg = get_option('shared-glapi')
115 if _sg == 'true'
116 _sg = 'enabled'
117 warning('shared-glapi option "true" deprecated, please use "enabled" instead.')
118 elif _sg == 'false'
119 _sg = 'disabled'
120 warning('shared-glapi option "false" deprecated, please use "disabled" instead.')
121 endif
122 if _sg == 'auto'
123 with_shared_glapi = host_machine.system() != 'windows'
124 else
125 with_shared_glapi = _sg == 'enabled'
126 endif
127
128 # shared-glapi is required if at least two OpenGL APIs are being built
129 if not with_shared_glapi
130 if ((with_gles1 == 'enabled' and with_gles2 == 'enabled') or
131 (with_gles1 == 'enabled' and with_opengl) or
132 (with_gles2 == 'enabled' and with_opengl))
133 error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
134 endif
135 with_gles1 = 'disabled'
136 with_gles2 = 'disabled'
137 endif
138
139 # We require OpenGL for OpenGL ES
140 if not with_opengl
141 if (with_gles1 == 'enabled' or with_gles2 == 'enabled') and not with_opengl
142 error('building OpenGL ES without OpenGL is not supported.')
143 endif
144 with_gles1 = 'disabled'
145 with_gles2 = 'disabled'
146 endif
147
148 with_gles1 = with_gles1 != 'disabled'
149 with_gles2 = with_gles2 != 'disabled'
150 with_any_opengl = with_opengl or with_gles1 or with_gles2
151 # Only build shared_glapi if at least one OpenGL API is enabled
152 with_shared_glapi = with_shared_glapi and with_any_opengl
153
154 system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos'].contains(host_machine.system())
155
156 dri_drivers = get_option('dri-drivers')
157 if dri_drivers.contains('auto')
158 if system_has_kms_drm
159 # TODO: PPC, Sparc
160 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
161 dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau']
162 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
163 dri_drivers = []
164 else
165 error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
166 host_machine.cpu_family()))
167 endif
168 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
169 # only swrast would make sense here, but gallium swrast is a much better default
170 dri_drivers = []
171 else
172 error('Unknown OS @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
173 host_machine.system()))
174 endif
175 endif
176
177 with_dri_i915 = dri_drivers.contains('i915')
178 with_dri_i965 = dri_drivers.contains('i965')
179 with_dri_r100 = dri_drivers.contains('r100')
180 with_dri_r200 = dri_drivers.contains('r200')
181 with_dri_nouveau = dri_drivers.contains('nouveau')
182 with_dri_swrast = dri_drivers.contains('swrast')
183
184 with_dri = dri_drivers.length() != 0 and dri_drivers != ['']
185
186 gallium_drivers = get_option('gallium-drivers')
187 if gallium_drivers.contains('auto')
188 if system_has_kms_drm
189 # TODO: PPC, Sparc
190 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
191 gallium_drivers = [
192 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast',
193 'iris'
194 ]
195 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
196 gallium_drivers = [
197 'kmsro', 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau',
198 'tegra', 'virgl', 'lima', 'panfrost', 'swrast'
199 ]
200 else
201 error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
202 host_machine.cpu_family()))
203 endif
204 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
205 gallium_drivers = ['swrast']
206 else
207 error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
208 host_machine.system()))
209 endif
210 endif
211 with_gallium_kmsro = gallium_drivers.contains('kmsro')
212 with_gallium_radeonsi = gallium_drivers.contains('radeonsi')
213 with_gallium_r300 = gallium_drivers.contains('r300')
214 with_gallium_r600 = gallium_drivers.contains('r600')
215 with_gallium_nouveau = gallium_drivers.contains('nouveau')
216 with_gallium_freedreno = gallium_drivers.contains('freedreno')
217 with_gallium_softpipe = gallium_drivers.contains('swrast')
218 with_gallium_vc4 = gallium_drivers.contains('vc4')
219 with_gallium_v3d = gallium_drivers.contains('v3d')
220 with_gallium_panfrost = gallium_drivers.contains('panfrost')
221 with_gallium_etnaviv = gallium_drivers.contains('etnaviv')
222 with_gallium_tegra = gallium_drivers.contains('tegra')
223 with_gallium_iris = gallium_drivers.contains('iris')
224 with_gallium_i915 = gallium_drivers.contains('i915')
225 with_gallium_svga = gallium_drivers.contains('svga')
226 with_gallium_virgl = gallium_drivers.contains('virgl')
227 with_gallium_swr = gallium_drivers.contains('swr')
228 with_gallium_lima = gallium_drivers.contains('lima')
229 with_gallium_zink = gallium_drivers.contains('zink')
230
231 with_gallium = gallium_drivers.length() != 0 and gallium_drivers != ['']
232
233 if with_gallium and system_has_kms_drm
234 _glx = get_option('glx')
235 _egl = get_option('egl')
236 if _glx == 'dri' or _egl == 'enabled' or (_glx == 'disabled' and _egl != 'disabled')
237 with_dri = true
238 endif
239 endif
240
241 _vulkan_drivers = get_option('vulkan-drivers')
242 if _vulkan_drivers.contains('auto')
243 if system_has_kms_drm
244 if host_machine.cpu_family().startswith('x86')
245 _vulkan_drivers = ['amd', 'intel']
246 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
247 _vulkan_drivers = []
248 else
249 error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
250 host_machine.cpu_family()))
251 endif
252 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
253 # No vulkan driver supports windows or macOS currently
254 _vulkan_drivers = []
255 else
256 error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
257 host_machine.system()))
258 endif
259 endif
260
261 with_intel_vk = _vulkan_drivers.contains('intel')
262 with_amd_vk = _vulkan_drivers.contains('amd')
263 with_freedreno_vk = _vulkan_drivers.contains('freedreno')
264 with_any_vk = _vulkan_drivers.length() != 0 and _vulkan_drivers != ['']
265
266 if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
267 error('Only one swrast provider can be built')
268 endif
269 if with_dri_i915 and with_gallium_i915
270 error('Only one i915 provider can be built')
271 endif
272 if with_gallium_kmsro and not (with_gallium_v3d or with_gallium_vc4 or with_gallium_etnaviv or with_gallium_freedreno or with_gallium_panfrost or with_gallium_lima)
273 error('kmsro driver requires one or more renderonly drivers (vc4, etnaviv, freedreno, panfrost, lima)')
274 endif
275 if with_gallium_tegra and not with_gallium_nouveau
276 error('tegra driver requires nouveau driver')
277 endif
278
279 if host_machine.system() == 'darwin'
280 with_dri_platform = 'apple'
281 pre_args += '-DBUILDING_MESA'
282 elif ['windows', 'cygwin'].contains(host_machine.system())
283 with_dri_platform = 'windows'
284 elif system_has_kms_drm
285 with_dri_platform = 'drm'
286 else
287 # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
288 # assert here that one of those cases has been met.
289 # FIXME: illumos ends up here as well
290 with_dri_platform = 'none'
291 endif
292
293 _platforms = get_option('platforms')
294 if _platforms.contains('auto')
295 if system_has_kms_drm
296 _platforms = ['x11', 'wayland', 'drm', 'surfaceless']
297 elif ['darwin', 'cygwin'].contains(host_machine.system())
298 _platforms = ['x11', 'surfaceless']
299 elif ['haiku'].contains(host_machine.system())
300 _platforms = ['haiku']
301 elif host_machine.system() == 'windows'
302 _platforms = ['windows']
303 else
304 error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format(
305 host_machine.system()))
306 endif
307 endif
308
309 with_platform_android = _platforms.contains('android')
310 with_platform_x11 = _platforms.contains('x11')
311 with_platform_wayland = _platforms.contains('wayland')
312 with_platform_drm = _platforms.contains('drm')
313 with_platform_haiku = _platforms.contains('haiku')
314 with_platform_surfaceless = _platforms.contains('surfaceless')
315 with_platform_windows = _platforms.contains('windows')
316
317 with_platforms = false
318 if _platforms.length() != 0 and _platforms != ['']
319 # sanity check that list contains no empty strings
320 if _platforms.contains('')
321 error('Invalid argument list given to -Dplatforms, please fix.')
322 endif
323 with_platforms = true
324 egl_native_platform = _platforms[0]
325 endif
326
327 _xlib_lease = get_option('xlib-lease')
328 if _xlib_lease == 'true'
329 _xlib_lease = 'enabled'
330 warning('xlib_lease option "true" deprecated, please use "enabled" instead.')
331 elif _xlib_lease == 'false'
332 _xlib_lease = 'disabled'
333 warning('xlib_lease option "false" deprecated, please use "disabled" instead.')
334 endif
335 if _xlib_lease == 'auto'
336 with_xlib_lease = with_platform_x11 and with_platform_drm
337 else
338 with_xlib_lease = _xlib_lease == 'enabled'
339 endif
340
341 with_glx = get_option('glx')
342 if with_glx == 'auto'
343 if with_dri
344 with_glx = 'dri'
345 elif with_platform_haiku
346 with_glx = 'disabled'
347 elif host_machine.system() == 'windows'
348 with_glx = 'disabled'
349 elif with_gallium
350 # Even when building just gallium drivers the user probably wants dri
351 with_glx = 'dri'
352 elif with_platform_x11 and with_any_opengl and not with_any_vk
353 # The automatic behavior should not be to turn on xlib based glx when
354 # building only vulkan drivers
355 with_glx = 'xlib'
356 else
357 with_glx = 'disabled'
358 endif
359 endif
360 if with_glx == 'dri'
361 if with_gallium
362 with_dri = true
363 endif
364 endif
365
366 if not (with_dri or with_gallium or with_glx != 'disabled')
367 with_gles1 = false
368 with_gles2 = false
369 with_opengl = false
370 with_any_opengl = false
371 with_shared_glapi = false
372 endif
373
374 _gbm = get_option('gbm')
375 if _gbm == 'true'
376 _gbm = 'enabled'
377 warning('gbm option "true" deprecated, please use "enabled" instead.')
378 elif _gbm == 'false'
379 _gbm = 'disabled'
380 warning('gbm option "false" deprecated, please use "disabled" instead.')
381 endif
382 if _gbm == 'auto'
383 with_gbm = system_has_kms_drm and with_dri
384 else
385 with_gbm = _gbm == 'enabled'
386 endif
387 if with_gbm and not system_has_kms_drm
388 error('GBM only supports DRM/KMS platforms')
389 endif
390
391 _egl = get_option('egl')
392 if _egl == 'true'
393 _egl = 'enabled'
394 warning('egl option "true" deprecated, please use "enabled" instead.')
395 elif _egl == 'false'
396 _egl = 'disabled'
397 warning('egl option "false" deprecated, please use "disabled" instead.')
398 endif
399 if _egl == 'auto'
400 with_egl = (
401 not ['darwin', 'windows'].contains(host_machine.system()) and
402 with_dri and with_shared_glapi and with_platforms
403 )
404 elif _egl == 'enabled'
405 if not with_dri
406 error('EGL requires dri')
407 elif not with_shared_glapi
408 error('EGL requires shared-glapi')
409 elif not with_platforms
410 error('No platforms specified, consider -Dplatforms=drm,x11,surfaceless at least')
411 elif not ['disabled', 'dri'].contains(with_glx)
412 error('EGL requires dri, but a GLX is being built without dri')
413 elif ['darwin', 'windows'].contains(host_machine.system())
414 error('EGL is not available on Windows or MacOS')
415 endif
416 with_egl = true
417 else
418 with_egl = false
419 endif
420
421 if with_egl and not (with_platform_drm or with_platform_surfaceless or with_platform_android)
422 if with_gallium_radeonsi
423 error('RadeonSI requires the drm, surfaceless or android platform when using EGL')
424 endif
425 if with_gallium_virgl
426 error('Virgl requires the drm, surfaceless or android platform when using EGL')
427 endif
428 endif
429
430 # Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS.
431 if host_machine.system() != 'windows' and (not with_platform_android or get_option('platform-sdk-version') >= 29)
432 pre_args += '-DUSE_ELF_TLS'
433 endif
434
435 if with_glx != 'disabled'
436 if not (with_platform_x11 and with_any_opengl)
437 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
438 elif with_glx == 'gallium-xlib'
439 if not with_gallium
440 error('Gallium-xlib based GLX requires at least one gallium driver')
441 elif not with_gallium_softpipe
442 error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
443 elif with_dri
444 error('gallium-xlib conflicts with any dri driver')
445 endif
446 elif with_glx == 'xlib'
447 if with_dri
448 error('xlib conflicts with any dri driver')
449 endif
450 elif with_glx == 'dri'
451 if not with_shared_glapi
452 error('dri based GLX requires shared-glapi')
453 endif
454 endif
455 endif
456
457 with_glvnd = get_option('glvnd')
458 if with_glvnd
459 if with_platform_windows
460 error('glvnd cannot be used on Windows')
461 elif with_glx == 'xlib' or with_glx == 'gallium-xlib'
462 error('Cannot build glvnd support for GLX that is not DRI based.')
463 elif with_glx == 'disabled' and not with_egl
464 error('glvnd requires DRI based GLX and/or EGL')
465 endif
466 if get_option('egl-lib-suffix') != ''
467 error('''EGL lib suffix can't be used with libglvnd''')
468 endif
469 endif
470
471 if with_vulkan_icd_dir == ''
472 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
473 endif
474
475 # GNU/Hurd includes egl_dri2, without drm.
476 with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or
477 host_machine.system() == 'gnu')
478 _dri3 = get_option('dri3')
479 if _dri3 == 'true'
480 _dri3 = 'enabled'
481 warning('dri3 option "true" deprecated, please use "enabled" instead.')
482 elif _dri3 == 'false'
483 _dri3 = 'disabled'
484 warning('dri3 option "false" deprecated, please use "disabled" instead.')
485 endif
486 if _dri3 == 'auto'
487 with_dri3 = system_has_kms_drm and with_dri2
488 else
489 with_dri3 = _dri3 == 'enabled'
490 endif
491
492 if with_any_vk and (with_platform_x11 and not with_dri3)
493 error('Vulkan drivers require dri3 for X11 support')
494 endif
495 if with_dri
496 if with_glx == 'disabled' and not with_egl and not with_gbm and with_osmesa != 'classic'
497 error('building dri drivers require at least one windowing system or classic osmesa')
498 endif
499 endif
500
501 _vdpau = get_option('gallium-vdpau')
502 if _vdpau == 'true'
503 _vdpau = 'enabled'
504 warning('gallium-vdpau option "true" deprecated, please use "enabled" instead.')
505 elif _vdpau == 'false'
506 _vdpau = 'disabled'
507 warning('gallium-vdpau option "false" deprecated, please use "disabled" instead.')
508 endif
509 if not system_has_kms_drm
510 if _vdpau == 'enabled'
511 error('VDPAU state tracker can only be build on unix-like OSes.')
512 else
513 _vdpau = 'disabled'
514 endif
515 elif not with_platform_x11
516 if _vdpau == 'enabled'
517 error('VDPAU state tracker requires X11 support.')
518 else
519 _vdpau = 'disabled'
520 endif
521 elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
522 with_gallium_nouveau)
523 if _vdpau == 'enabled'
524 error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.')
525 else
526 _vdpau = 'disabled'
527 endif
528 endif
529 dep_vdpau = null_dep
530 with_gallium_vdpau = false
531 if _vdpau != 'disabled'
532 dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'enabled')
533 if dep_vdpau.found()
534 dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
535 with_gallium_vdpau = true
536 endif
537 endif
538
539 if with_gallium_vdpau
540 pre_args += '-DHAVE_ST_VDPAU'
541 endif
542 vdpau_drivers_path = get_option('vdpau-libs-path')
543 if vdpau_drivers_path == ''
544 vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
545 endif
546
547 if with_gallium_zink
548 dep_vulkan = dependency('vulkan')
549 endif
550
551 _xvmc = get_option('gallium-xvmc')
552 if _xvmc == 'true'
553 _xvmc = 'enabled'
554 warning('gallium-xvmc option "true" deprecated, please use "enabled" instead.')
555 elif _xvmc == 'false'
556 _xvmc = 'disabled'
557 warning('gallium-xvmc option "false" deprecated, please use "disabled" instead.')
558 endif
559 if not system_has_kms_drm
560 if _xvmc == 'enabled'
561 error('XVMC state tracker can only be build on unix-like OSes.')
562 else
563 _xvmc = 'disabled'
564 endif
565 elif not with_platform_x11
566 if _xvmc == 'enabled'
567 error('XVMC state tracker requires X11 support.')
568 else
569 _xvmc = 'disabled'
570 endif
571 elif not (with_gallium_r600 or with_gallium_nouveau)
572 if _xvmc == 'enabled'
573 error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.')
574 else
575 _xvmc = 'disabled'
576 endif
577 endif
578 dep_xvmc = null_dep
579 dep_xv = null_dep
580 with_gallium_xvmc = false
581 if _xvmc != 'disabled'
582 dep_xvmc = dependency('xvmc', version : '>= 1.0.6', required : _xvmc == 'enabled')
583 dep_xv = dependency('xv', required : _xvmc == 'enabled')
584 with_gallium_xvmc = dep_xvmc.found() and dep_xv.found()
585 endif
586
587 xvmc_drivers_path = get_option('xvmc-libs-path')
588 if xvmc_drivers_path == ''
589 xvmc_drivers_path = get_option('libdir')
590 endif
591
592 _omx = get_option('gallium-omx')
593 if not system_has_kms_drm
594 if ['auto', 'disabled'].contains(_omx)
595 _omx = 'disabled'
596 else
597 error('OMX state tracker can only be built on unix-like OSes.')
598 endif
599 elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
600 if ['auto', 'disabled'].contains(_omx)
601 _omx = 'disabled'
602 else
603 error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
604 endif
605 endif
606 with_gallium_omx = _omx
607 dep_omx = null_dep
608 dep_omx_other = []
609 if ['auto', 'bellagio'].contains(_omx)
610 dep_omx = dependency(
611 'libomxil-bellagio', required : _omx == 'bellagio'
612 )
613 if dep_omx.found()
614 with_gallium_omx = 'bellagio'
615 endif
616 endif
617 if ['auto', 'tizonia'].contains(_omx)
618 if with_dri and with_egl
619 dep_omx = dependency(
620 'libtizonia', version : '>= 0.10.0',
621 required : _omx == 'tizonia',
622 )
623 dep_omx_other = [
624 dependency('libtizplatform', required : _omx == 'tizonia'),
625 dependency('tizilheaders', required : _omx == 'tizonia'),
626 ]
627 if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
628 with_gallium_omx = 'tizonia'
629 endif
630 elif _omx == 'tizonia'
631 error('OMX-Tizonia state tracker requires dri and egl')
632 endif
633 endif
634 if _omx == 'auto'
635 with_gallium_omx = 'disabled'
636 else
637 with_gallium_omx = _omx
638 endif
639
640 pre_args += [
641 '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'),
642 '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'),
643 ]
644
645
646 omx_drivers_path = get_option('omx-libs-path')
647
648 if with_gallium_omx != 'disabled'
649 # Figure out where to put the omx driver.
650 # FIXME: this could all be vastly simplified by adding a 'defined_variable'
651 # argument to meson's get_pkgconfig_variable method.
652 if omx_drivers_path == ''
653 _omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
654 _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
655 if _omx_libdir == get_option('libdir')
656 omx_drivers_path = _omx_drivers_dir
657 else
658 _omx_base_dir = []
659 # This will fail on windows. Does OMX run on windows?
660 _omx_libdir = _omx_libdir.split('/')
661 _omx_drivers_dir = _omx_drivers_dir.split('/')
662 foreach o : _omx_drivers_dir
663 if not _omx_libdir.contains(o)
664 _omx_base_dir += o
665 endif
666 endforeach
667 omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
668 endif
669 endif
670 endif
671
672 _va = get_option('gallium-va')
673 if _va == 'true'
674 _va = 'enabled'
675 warning('gallium-va option "true" deprecated, please use "enabled" instead.')
676 elif _va == 'false'
677 _va = 'disabled'
678 warning('gallium-va option "false" deprecated, please use "disabled" instead.')
679 endif
680 if not system_has_kms_drm
681 if _va == 'enabled'
682 error('VA state tracker can only be built on unix-like OSes.')
683 else
684 _va = 'disabled'
685 endif
686 elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
687 if _va == 'enabled'
688 error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
689 else
690 _va = 'disabled'
691 endif
692 endif
693 with_gallium_va = false
694 dep_va = null_dep
695 if _va != 'disabled'
696 dep_va = dependency('libva', version : '>= 0.38.0', required : _va == 'enabled')
697 if dep_va.found()
698 dep_va_headers = dep_va.partial_dependency(compile_args : true)
699 with_gallium_va = true
700 endif
701 endif
702
703 va_drivers_path = get_option('va-libs-path')
704 if va_drivers_path == ''
705 va_drivers_path = join_paths(get_option('libdir'), 'dri')
706 endif
707
708 _xa = get_option('gallium-xa')
709 if _xa == 'true'
710 _xa = 'enabled'
711 warning('gallium-xa option "true" deprecated, please use "enabled" instead.')
712 elif _xa == 'false'
713 _xa = 'disabled'
714 warning('gallium-xa option "false" deprecated, please use "disabled" instead.')
715 endif
716 if not system_has_kms_drm
717 if _xa == 'enabled'
718 error('XA state tracker can only be built on unix-like OSes.')
719 else
720 _xa = 'disabled'
721 endif
722 elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
723 or with_gallium_svga)
724 if _xa == 'enabled'
725 error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.')
726 else
727 _xa = 'disabled'
728 endif
729 endif
730 with_gallium_xa = _xa != 'disabled'
731
732 d3d_drivers_path = get_option('d3d-drivers-path')
733 if d3d_drivers_path == ''
734 d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d')
735 endif
736
737 with_gallium_st_nine = get_option('gallium-nine')
738 if with_gallium_st_nine
739 if not with_gallium_softpipe
740 error('The nine state tracker requires gallium softpipe/llvmpipe.')
741 elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600
742 or with_gallium_r300 or with_gallium_svga or with_gallium_i915
743 or with_gallium_iris)
744 error('The nine state tracker requires at least one non-swrast gallium driver.')
745 endif
746 if not with_dri3
747 error('Using nine with wine requires dri3')
748 endif
749 endif
750 _power8 = get_option('power8')
751 if _power8 == 'true'
752 _power8 = 'enabled'
753 warning('power8 option "true" deprecated, please use "enabled" instead.')
754 elif _power8 == 'disabled'
755 _power8 = 'disabled'
756 warning('power8 option "false" deprecated, please use "disabled" instead.')
757 endif
758 if _power8 != 'disabled'
759 # on old versions of meson the cpu family would return as ppc64le on little
760 # endian power8, this was changed in 0.48 such that the family would always
761 # be ppc64 regardless of endianness, and then the machine.endian() value
762 # should be checked. Since we support versions < 0.48 we need to use
763 # startswith.
764 if host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
765 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
766 error('Altivec is not supported with gcc version < 4.8.')
767 endif
768 if cc.compiles('''
769 #include <altivec.h>
770 int main() {
771 vector unsigned char r;
772 vector unsigned int v = vec_splat_u32 (1);
773 r = __builtin_vec_vgbbd ((vector unsigned char) v);
774 return 0;
775 }''',
776 args : '-mpower8-vector',
777 name : 'POWER8 intrinsics')
778 pre_args += ['-D_ARCH_PWR8', '-mpower8-vector']
779 elif get_option('power8') == 'enabled'
780 error('POWER8 intrinsic support required but not found.')
781 endif
782 endif
783 endif
784
785 _opencl = get_option('gallium-opencl')
786 clover_cpp_std = []
787 if _opencl != 'disabled'
788 if not with_gallium
789 error('OpenCL Clover implementation requires at least one gallium driver.')
790 endif
791
792 dep_clc = dependency('libclc')
793 with_gallium_opencl = true
794 with_opencl_icd = _opencl == 'icd'
795
796 with_opencl_spirv = get_option('opencl-spirv')
797 if with_opencl_spirv
798 dep_spirv_tools = dependency('SPIRV-Tools', required : true, version : '>= 2018.0')
799 # LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator
800 dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : '>= 0.2.1')
801 else
802 dep_spirv_tools = null_dep
803 dep_llvmspirvlib = null_dep
804 endif
805
806 if host_machine.cpu_family().startswith('ppc') and cpp.compiles('''
807 #if !defined(__VEC__) || !defined(__ALTIVEC__)
808 #error "AltiVec not enabled"
809 #endif''',
810 name : 'Altivec')
811 clover_cpp_std += ['cpp_std=gnu++11']
812 endif
813 else
814 dep_clc = null_dep
815 dep_spirv_tools = null_dep
816 dep_llvmspirvlib = null_dep
817 with_gallium_opencl = false
818 with_opencl_icd = false
819 with_opencl_spirv = false
820 endif
821
822 gl_pkgconfig_c_flags = []
823 if with_platform_x11
824 if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
825 pre_args += '-DHAVE_X11_PLATFORM'
826 endif
827 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
828 pre_args += '-DUSE_XSHM'
829 else
830 pre_args += '-DGLX_INDIRECT_RENDERING'
831 if with_glx_direct
832 pre_args += '-DGLX_DIRECT_RENDERING'
833 endif
834 if with_dri_platform == 'drm'
835 pre_args += '-DGLX_USE_DRM'
836 elif with_dri_platform == 'apple'
837 pre_args += '-DGLX_USE_APPLEGL'
838 elif with_dri_platform == 'windows'
839 pre_args += '-DGLX_USE_WINDOWSGL'
840 endif
841 endif
842 else
843 pre_args += '-DEGL_NO_X11'
844 gl_pkgconfig_c_flags += '-DEGL_NO_X11'
845 endif
846 if with_platform_drm
847 if with_egl and not with_gbm
848 error('EGL drm platform requires gbm')
849 endif
850 pre_args += '-DHAVE_DRM_PLATFORM'
851 endif
852 if with_platform_surfaceless
853 pre_args += '-DHAVE_SURFACELESS_PLATFORM'
854 endif
855 if with_platform_android
856 dep_android = [
857 dependency('cutils'),
858 dependency('hardware'),
859 dependency('sync'),
860 ]
861 if with_gallium
862 dep_android += dependency('backtrace')
863 endif
864 if get_option('platform-sdk-version') >= 26
865 dep_android += dependency('nativewindow')
866 endif
867 pre_args += '-DHAVE_ANDROID_PLATFORM'
868 endif
869 if with_platform_haiku
870 pre_args += '-DHAVE_HAIKU_PLATFORM'
871 endif
872
873 prog_python = import('python').find_installation('python3')
874 has_mako = run_command(
875 prog_python, '-c',
876 '''
877 from distutils.version import StrictVersion
878 import mako
879 assert StrictVersion(mako.__version__) > StrictVersion("0.8.0")
880 ''')
881 if has_mako.returncode() != 0
882 error('Python (3.x) mako module >= 0.8.0 required to build mesa.')
883 endif
884
885 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
886 error('When using GCC, version 4.4.6 or later is required.')
887 endif
888
889 # Support systems without ETIME (e.g. FreeBSD)
890 if cc.get_define('ETIME', prefix : '#include <errno.h>') == ''
891 pre_args += '-DETIME=ETIMEDOUT'
892 endif
893
894 # Define DEBUG for debug builds only (debugoptimized is not included on this one)
895 if get_option('buildtype') == 'debug'
896 pre_args += '-DDEBUG'
897 endif
898
899 with_shader_cache = false
900 _shader_cache = get_option('shader-cache')
901 if _shader_cache == 'true'
902 _shader_cache = 'enabled'
903 warning('shader_cache option "true" deprecated, please use "enabled" instead.')
904 elif _shader_cache == 'false'
905 _shader_cache = 'disabled'
906 warning('shader_cache option "false" deprecated, please use "disabled" instead.')
907 endif
908 if _shader_cache != 'disabled'
909 if host_machine.system() == 'windows'
910 if _shader_cache == 'enabled'
911 error('Shader Cache does not currently work on Windows')
912 endif
913 else
914 pre_args += '-DENABLE_SHADER_CACHE'
915 with_shader_cache = true
916 endif
917 endif
918 if with_amd_vk and not with_shader_cache
919 error('Radv requires shader cache support')
920 endif
921
922 # Check for GCC style builtins
923 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
924 'ffsll', 'popcount', 'popcountll', 'unreachable']
925 if cc.has_function(b)
926 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
927 endif
928 endforeach
929
930 # check for GCC __attribute__
931 _attributes = [
932 'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result',
933 'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn',
934 ]
935 foreach a : cc.get_supported_function_attributes(_attributes)
936 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
937 endforeach
938 if cc.has_function_attribute('visibility:hidden')
939 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
940 endif
941 if cc.compiles('__uint128_t foo(void) { return 0; }',
942 name : '__uint128_t')
943 pre_args += '-DHAVE_UINT128'
944 endif
945
946 # TODO: this is very incomplete
947 if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd'].contains(host_machine.system())
948 pre_args += '-D_GNU_SOURCE'
949 elif host_machine.system() == 'sunos'
950 pre_args += '-D__EXTENSIONS__'
951 elif host_machine.system() == 'windows'
952 pre_args += [
953 '-D_WINDOWS', '-D_WIN32_WINNT=0x0601', '-DWINVER=0x0601',
954 '-DPIPE_SUBSYSTEM_WINDOWS_USER',
955 '-D_USE_MATH_DEFINES', # XXX: scons doesn't use this for mingw
956 ]
957 if cc.get_id() == 'msvc'
958 pre_args += [
959 '-DVC_EXTRALEAN',
960 '-D_CRT_SECURE_NO_WARNINGS',
961 '-D_CRT_SECURE_NO_DEPRECATE',
962 '-D_SCL_SECURE_NO_WARNINGS',
963 '-D_SCL_SECURE_NO_DEPRECATE',
964 '-D_ALLOW_KEYWORD_MACROS',
965 '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
966 ]
967 else
968 pre_args += ['-D__MSVCRT_VERSION__=0x0700']
969 endif
970 endif
971
972 # Check for generic C arguments
973 c_args = []
974 c_msvc_compat_args = []
975 no_override_init_args = []
976 cpp_args = []
977 cpp_msvc_compat_args = []
978 if cc.get_id() == 'msvc'
979 foreach a : ['/wd4018', # signed/unsigned mismatch
980 '/wd4056', # overflow in floating-point constant arithmetic
981 '/wd4244', # conversion from 'type1' to 'type2', possible loss of data
982 '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data
983 '/wd4305', # trancation from 'type1' to 'type2'
984 '/wd4351', # new behavior: elements of array 'array' will be default initialized
985 '/wd4756', # overflow in constant arithmetic
986 '/wd4800', # forcing value to bool 'true' or 'false' (performance warning)
987 '/wd4996', # disabled deprecated POSIX name warnings
988 '/wd4291', # no matching operator delete found
989 '/wd4146', # unary minus operator applied to unsigned type, result still unsigned
990 '/wd4200', # nonstandard extension used: zero-sized array in struct/union
991 '/wd4624', # destructor was implicitly defined as deleted [from LLVM]
992 ]
993 if cc.has_argument(a)
994 c_args += a
995 endif
996 if cpp.has_argument(a)
997 cpp_args += a
998 endif
999 endforeach
1000 if cc.has_argument('-Wmicrosoft-enum-value') # Clang
1001 c_args += '-Wno-microsoft-enum-value'
1002 cpp_args += '-Wno-microsoft-enum-value'
1003 endif
1004 else
1005 _trial = [
1006 '-Werror=implicit-function-declaration',
1007 '-Werror=missing-prototypes',
1008 '-Werror=return-type',
1009 '-Werror=empty-body',
1010 '-Werror=incompatible-pointer-types',
1011 '-Werror=int-conversion',
1012 '-Wno-missing-field-initializers',
1013 '-Wno-format-truncation',
1014 '-fno-math-errno',
1015 '-fno-trapping-math',
1016 '-Qunused-arguments',
1017 '-fno-common',
1018 ]
1019 # MinGW chokes on format specifiers and I can't get it all working
1020 if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows')
1021 _trial += ['-Werror=format', '-Wformat-security']
1022 endif
1023 foreach a : _trial
1024 if cc.has_argument(a)
1025 c_args += a
1026 endif
1027 endforeach
1028
1029 _trial = [
1030 '-Werror=return-type',
1031 '-Werror=empty-body',
1032 '-Wno-non-virtual-dtor',
1033 '-Wno-missing-field-initializers',
1034 '-Wno-format-truncation',
1035 '-fno-math-errno',
1036 '-fno-trapping-math',
1037 '-Qunused-arguments',
1038 # Some classes use custom new operator which zeroes memory, however
1039 # gcc does aggressive dead-store elimination which threats all writes
1040 # to the memory before the constructor as "dead stores".
1041 # For now we disable this optimization.
1042 '-flifetime-dse=1',
1043 ]
1044 # MinGW chokes on format specifiers and I can't get it all working
1045 if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows')
1046 _trial += ['-Werror=format', '-Wformat-security']
1047 endif
1048 foreach a : _trial
1049 if cpp.has_argument(a)
1050 cpp_args += a
1051 endif
1052 endforeach
1053
1054 foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
1055 if cc.has_argument(a)
1056 no_override_init_args += a
1057 endif
1058 endforeach
1059
1060 # Check for C and C++ arguments for MSVC compatibility. These are only used
1061 # in parts of the mesa code base that need to compile with MSVC, mainly
1062 # common code
1063 foreach a : ['-Werror=pointer-arith', '-Werror=vla', '-Werror=gnu-empty-initializer']
1064 if cc.has_argument(a)
1065 c_msvc_compat_args += a
1066 endif
1067 if cpp.has_argument(a)
1068 cpp_msvc_compat_args += a
1069 endif
1070 endforeach
1071 endif
1072
1073 # set linker arguments
1074 if host_machine.system() == 'windows'
1075 if cc.get_id() == 'msvc'
1076 add_project_link_arguments(
1077 '/fixed:no',
1078 '/dynamicbase',
1079 '/nxcompat',
1080 language : ['c', 'cpp'],
1081 )
1082 if get_option('buildtype') != 'debug'
1083 add_project_link_arguments(
1084 '/incremental:no',
1085 language : ['c', 'cpp'],
1086 )
1087 endif
1088 else
1089 add_project_link_arguments(
1090 '-Wl,--nxcompat',
1091 '-Wl,--dynamicbase',
1092 '-static-libgcc',
1093 '-static-libstdc++',
1094 language : ['c', 'cpp'],
1095 )
1096 endif
1097 endif
1098
1099 if host_machine.cpu_family().startswith('x86') and cc.get_id() != 'msvc'
1100 pre_args += '-DUSE_SSE41'
1101 with_sse41 = true
1102 sse41_args = ['-msse4.1']
1103
1104 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
1105 # that's not guaranteed
1106 if host_machine.cpu_family() == 'x86'
1107 sse41_args += '-mstackrealign'
1108 endif
1109 else
1110 with_sse41 = false
1111 sse41_args = []
1112 endif
1113
1114 # Check for GCC style atomics
1115 dep_atomic = null_dep
1116
1117 if cc.compiles('''#include <stdint.h>
1118 int main() {
1119 struct {
1120 uint64_t *v;
1121 } x;
1122 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1123 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1124
1125 }''',
1126 name : 'GCC atomic builtins')
1127 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
1128
1129 # Not all atomic calls can be turned into lock-free instructions, in which
1130 # GCC will make calls into the libatomic library. Check whether we need to
1131 # link with -latomic.
1132 #
1133 # This can happen for 64-bit atomic operations on 32-bit architectures such
1134 # as ARM.
1135 if not cc.links('''#include <stdint.h>
1136 int main() {
1137 struct {
1138 uint64_t *v;
1139 } x;
1140 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
1141 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
1142 }''',
1143 name : 'GCC atomic builtins required -latomic')
1144 dep_atomic = cc.find_library('atomic')
1145 endif
1146 endif
1147 if not cc.links('''#include <stdint.h>
1148 uint64_t v;
1149 int main() {
1150 return __sync_add_and_fetch(&v, (uint64_t)1);
1151 }''',
1152 dependencies : dep_atomic,
1153 name : 'GCC 64bit atomics')
1154 pre_args += '-DMISSING_64BIT_ATOMICS'
1155 endif
1156
1157 dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows)
1158
1159 # TODO: shared/static? Is this even worth doing?
1160
1161 with_asm_arch = ''
1162 if host_machine.cpu_family() == 'x86'
1163 if system_has_kms_drm or host_machine.system() == 'gnu'
1164 with_asm_arch = 'x86'
1165 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
1166 '-DUSE_SSE_ASM']
1167
1168 if with_glx_read_only_text
1169 pre_args += ['-DGLX_X86_READONLY_TEXT']
1170 endif
1171 endif
1172 elif host_machine.cpu_family() == 'x86_64'
1173 if system_has_kms_drm
1174 with_asm_arch = 'x86_64'
1175 pre_args += ['-DUSE_X86_64_ASM']
1176 endif
1177 elif host_machine.cpu_family() == 'arm'
1178 if system_has_kms_drm
1179 with_asm_arch = 'arm'
1180 pre_args += ['-DUSE_ARM_ASM']
1181 endif
1182 elif host_machine.cpu_family() == 'aarch64'
1183 if system_has_kms_drm
1184 with_asm_arch = 'aarch64'
1185 pre_args += ['-DUSE_AARCH64_ASM']
1186 endif
1187 elif host_machine.cpu_family() == 'sparc64'
1188 if system_has_kms_drm
1189 with_asm_arch = 'sparc'
1190 pre_args += ['-DUSE_SPARC_ASM']
1191 endif
1192 elif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
1193 if system_has_kms_drm
1194 with_asm_arch = 'ppc64le'
1195 pre_args += ['-DUSE_PPC64LE_ASM']
1196 endif
1197 endif
1198
1199 # Check for standard headers and functions
1200 if (cc.has_header_symbol('sys/sysmacros.h', 'major') and
1201 cc.has_header_symbol('sys/sysmacros.h', 'minor') and
1202 cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
1203 pre_args += '-DMAJOR_IN_SYSMACROS'
1204 endif
1205 if (cc.has_header_symbol('sys/mkdev.h', 'major') and
1206 cc.has_header_symbol('sys/mkdev.h', 'minor') and
1207 cc.has_header_symbol('sys/mkdev.h', 'makedev'))
1208 pre_args += '-DMAJOR_IN_MKDEV'
1209 endif
1210
1211 foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h', 'sys/shm.h', 'cet.h']
1212 if cc.check_header(h)
1213 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
1214 endif
1215 endforeach
1216
1217 foreach f : ['strtof', 'mkostemp', 'timespec_get', 'memfd_create', 'random_r', 'flock', 'strtok_r', 'getrandom']
1218 if cc.has_function(f)
1219 pre_args += '-DHAVE_@0@'.format(f.to_upper())
1220 endif
1221 endforeach
1222
1223 if cc.has_header_symbol('errno.h', 'program_invocation_name',
1224 args : '-D_GNU_SOURCE')
1225 pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'
1226 elif with_tools.contains('intel')
1227 error('Intel tools require the program_invocation_name variable')
1228 endif
1229
1230 # MinGW provides a __builtin_posix_memalign function, but not a posix_memalign.
1231 # This means that this check will succeed, but then compilation will later
1232 # fail. MSVC doesn't have this function at all, so only check for it on
1233 # non-windows platforms.
1234 if host_machine.system() != 'windows'
1235 if cc.has_function('posix_memalign')
1236 pre_args += '-DHAVE_POSIX_MEMALIGN'
1237 endif
1238 endif
1239
1240 if cc.has_member('struct dirent', 'd_type', prefix: '''#include <sys/types.h>
1241 #include <dirent.h>''')
1242 pre_args += '-DHAVE_DIRENT_D_TYPE'
1243 endif
1244
1245 # strtod locale support
1246 if cc.links('''
1247 #define _GNU_SOURCE
1248 #include <stdlib.h>
1249 #include <locale.h>
1250 #ifdef HAVE_XLOCALE_H
1251 #include <xlocale.h>
1252 #endif
1253 int main() {
1254 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
1255 const char *s = "1.0";
1256 char *end;
1257 double d = strtod_l(s, end, loc);
1258 float f = strtof_l(s, end, loc);
1259 freelocale(loc);
1260 return 0;
1261 }''',
1262 args : pre_args,
1263 name : 'strtod has locale support')
1264 pre_args += '-DHAVE_STRTOD_L'
1265 endif
1266
1267 # Check for some linker flags
1268 ld_args_bsymbolic = []
1269 if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
1270 ld_args_bsymbolic += '-Wl,-Bsymbolic'
1271 endif
1272 ld_args_gc_sections = []
1273 if cc.links('static char unused() { return 5; } int main() { return 0; }',
1274 args : '-Wl,--gc-sections', name : 'gc-sections')
1275 ld_args_gc_sections += '-Wl,--gc-sections'
1276 endif
1277 with_ld_version_script = false
1278 if cc.links('int main() { return 0; }',
1279 args : '-Wl,--version-script=@0@'.format(
1280 join_paths(meson.source_root(), 'build-support/conftest.map')),
1281 name : 'version-script')
1282 with_ld_version_script = true
1283 endif
1284 with_ld_dynamic_list = false
1285 if cc.links('int main() { return 0; }',
1286 args : '-Wl,--dynamic-list=@0@'.format(
1287 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
1288 name : 'dynamic-list')
1289 with_ld_dynamic_list = true
1290 endif
1291
1292 ld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1')
1293
1294 # check for dl support
1295 dep_dl = null_dep
1296 if not cc.has_function('dlopen')
1297 dep_dl = cc.find_library('dl', required : host_machine.system() != 'windows')
1298 endif
1299 if cc.has_function('dladdr', dependencies : dep_dl)
1300 # This is really only required for megadrivers
1301 pre_args += '-DHAVE_DLADDR'
1302 endif
1303
1304 if cc.has_function('dl_iterate_phdr')
1305 pre_args += '-DHAVE_DL_ITERATE_PHDR'
1306 elif with_intel_vk
1307 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
1308 elif with_dri_i965 and with_shader_cache
1309 error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
1310 endif
1311
1312 # Determine whether or not the rt library is needed for time functions
1313 if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
1314 dep_clock = null_dep
1315 else
1316 dep_clock = cc.find_library('rt')
1317 endif
1318
1319 # TODO: some of these may be conditional
1320 dep_zlib = dependency('zlib', version : '>= 1.2.3', fallback : ['zlib', 'zlib_dep'])
1321 pre_args += '-DHAVE_ZLIB'
1322
1323 _zstd = get_option('zstd')
1324 if _zstd == 'true'
1325 _zstd = 'enabled'
1326 warning('zstd option "true" deprecated, please use "enabled" instead.')
1327 elif _zstd == 'false'
1328 _zstd = 'disabled'
1329 warning('zstd option "false" deprecated, please use "disabled" instead.')
1330 endif
1331 if _zstd != 'disabled'
1332 dep_zstd = dependency('libzstd', required : _zstd == 'enabled')
1333 if dep_zstd.found()
1334 pre_args += '-DHAVE_ZSTD'
1335 endif
1336 else
1337 dep_zstd = null_dep
1338 endif
1339
1340 dep_thread = dependency('threads')
1341 if dep_thread.found() and host_machine.system() != 'windows'
1342 pre_args += '-DHAVE_PTHREAD'
1343 if cc.has_function(
1344 'pthread_setaffinity_np',
1345 dependencies : dep_thread,
1346 prefix : '#include <pthread.h>',
1347 args : '-D_GNU_SOURCE')
1348 pre_args += '-DHAVE_PTHREAD_SETAFFINITY'
1349 endif
1350 if cc.has_function(
1351 'pthread_setaffinity_np',
1352 dependencies : dep_thread,
1353 prefix : '#include <pthread_np.h>')
1354 pre_args += '-DPTHREAD_SETAFFINITY_IN_NP_HEADER'
1355 endif
1356 endif
1357 if host_machine.system() != 'windows'
1358 dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'])
1359 else
1360 dep_expat = null_dep
1361 endif
1362 # this only exists on linux so either this is linux and it will be found, or
1363 # it's not linux and wont
1364 dep_m = cc.find_library('m', required : false)
1365
1366 # Check for libdrm. Various drivers have different libdrm version requirements,
1367 # but we always want to use the same version for all libdrm modules. That means
1368 # even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and
1369 # bar are both on use 2.4.3 for both of them
1370 dep_libdrm_amdgpu = null_dep
1371 dep_libdrm_radeon = null_dep
1372 dep_libdrm_nouveau = null_dep
1373 dep_libdrm_intel = null_dep
1374
1375 _drm_amdgpu_ver = '2.4.100'
1376 _drm_radeon_ver = '2.4.71'
1377 _drm_nouveau_ver = '2.4.66'
1378 _drm_intel_ver = '2.4.75'
1379 _drm_ver = '2.4.81'
1380
1381 _libdrm_checks = [
1382 ['intel', with_dri_i915 or with_gallium_i915],
1383 ['amdgpu', with_amd_vk or with_gallium_radeonsi],
1384 ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
1385 with_gallium_r300 or with_gallium_r600)],
1386 ['nouveau', (with_gallium_nouveau or with_dri_nouveau)],
1387 ]
1388
1389 # VC4 only needs core libdrm support of this version, not a libdrm_vc4
1390 # library.
1391 if with_gallium_vc4
1392 _drm_ver = '2.4.89'
1393 endif
1394
1395 # etnaviv only needs core libdrm
1396 if with_gallium_etnaviv
1397 _drm_ver = '2.4.89'
1398 endif
1399
1400 # Loop over the enables versions and get the highest libdrm requirement for all
1401 # active drivers.
1402 _drm_blame = ''
1403 foreach d : _libdrm_checks
1404 ver = get_variable('_drm_@0@_ver'.format(d[0]))
1405 if d[1] and ver.version_compare('>' + _drm_ver)
1406 _drm_ver = ver
1407 _drm_blame = d[0]
1408 endif
1409 endforeach
1410 if _drm_blame != ''
1411 message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame))
1412 endif
1413
1414 # Then get each libdrm module
1415 foreach d : _libdrm_checks
1416 if d[1]
1417 set_variable(
1418 'dep_libdrm_' + d[0],
1419 dependency('libdrm_' + d[0], version : '>=' + _drm_ver)
1420 )
1421 endif
1422 endforeach
1423
1424 with_gallium_drisw_kms = false
1425 dep_libdrm = dependency(
1426 'libdrm', version : '>=' + _drm_ver,
1427 # GNU/Hurd includes egl_dri2, without drm.
1428 required : (with_dri2 and host_machine.system() != 'gnu') or with_dri3
1429 )
1430 if dep_libdrm.found()
1431 pre_args += '-DHAVE_LIBDRM'
1432 if with_dri_platform == 'drm' and with_dri
1433 with_gallium_drisw_kms = true
1434 endif
1435 endif
1436
1437 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit', 'core', 'executionengine', 'scalaropts', 'transformutils', 'instcombine']
1438 llvm_optional_modules = ['coroutines']
1439 if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
1440 llvm_modules += ['amdgpu', 'native', 'bitreader', 'ipo']
1441 if with_gallium_r600
1442 llvm_modules += 'asmparser'
1443 endif
1444 endif
1445 if with_gallium_opencl
1446 llvm_modules += [
1447 'all-targets', 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
1448 'lto', 'option', 'objcarcopts', 'profiledata',
1449 ]
1450 endif
1451
1452 if with_amd_vk or with_gallium_radeonsi
1453 _llvm_version = '>= 8.0.0'
1454 elif with_gallium_swr
1455 _llvm_version = '>= 6.0.0'
1456 else
1457 _llvm_version = '>= 3.9.0'
1458 endif
1459
1460 _shared_llvm = get_option('shared-llvm')
1461 if _shared_llvm == 'true'
1462 _shared_llvm = 'enabled'
1463 warning('shared_llvm option "true" deprecated, please use "enabled" instead.')
1464 elif _shared_llvm == 'false'
1465 _shared_llvm = 'disabled'
1466 warning('shared_llvm option "false" deprecated, please use "disabled" instead.')
1467 endif
1468 if _shared_llvm == 'auto'
1469 _shared_llvm = (host_machine.system() != 'windows')
1470 else
1471 _shared_llvm = (_shared_llvm == 'enabled')
1472 endif
1473 _llvm = get_option('llvm')
1474 if _llvm == 'true'
1475 _llvm = 'enabled'
1476 warning('llvm option "true" deprecated, please use "enabled" instead.')
1477 elif _llvm == 'false'
1478 _llvm = 'disabled'
1479 warning('llvm option "false" deprecated, please use "disabled" instead.')
1480 endif
1481
1482 # the cmake method can only link statically, so don't attempt to use it if we
1483 # want to link dynamically. Before 0.54.0 meson will try cmake even when shared
1484 # linking is requested, so we need to force the config-tool method to be used
1485 # in that case, but in 0.54.0 meson won't try the cmake method if shared
1486 # linking is requested.
1487 _llvm_method = 'auto'
1488 if meson.version().version_compare('< 0.54.0') and _shared_llvm
1489 _llvm_method = 'config-tool'
1490 endif
1491
1492 dep_llvm = null_dep
1493 with_llvm = false
1494 if _llvm != 'disabled'
1495 dep_llvm = dependency(
1496 'llvm',
1497 version : _llvm_version,
1498 modules : llvm_modules,
1499 optional_modules : llvm_optional_modules,
1500 required : (
1501 with_amd_vk or with_gallium_radeonsi or with_gallium_swr or
1502 with_gallium_opencl or _llvm == 'enabled'
1503 ),
1504 static : not _shared_llvm,
1505 method : _llvm_method,
1506 fallback : ['llvm', 'dep_llvm'],
1507 )
1508 with_llvm = dep_llvm.found()
1509 endif
1510 if with_llvm
1511 pre_args += '-DLLVM_AVAILABLE'
1512 pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version())
1513
1514 # LLVM can be built without rtti, turning off rtti changes the ABI of C++
1515 # programs, so we need to build all C++ code in mesa without rtti as well to
1516 # ensure that linking works.
1517 #
1518 # In meson 0.51.0 we can use cmake to find LLVM in addittion to meson's
1519 # builtin llvm-config based finder. A new generic variable getter method
1520 # has also been added, so we'll use that if we can, to cover the cmake case.
1521 if dep_llvm.type_name() == 'internal'
1522 _rtti = subproject('llvm').get_variable('has_rtti', true)
1523 else
1524 # The CMake finder will return 'ON', the llvm-config will return 'YES'
1525 _rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
1526 endif
1527 if not _rtti
1528 if with_gallium_nouveau
1529 error('The Nouveau driver requires rtti. You either need to turn off nouveau or use an LLVM built with LLVM_ENABLE_RTTI.')
1530 elif with_gallium_opencl
1531 error('The Clover OpenCL state tracker requires rtti, you need to turn off clover or use an LLVM built with LLVM_ENABLE_RTTI.')
1532 endif
1533 if cc.get_id() == 'msvc'
1534 cpp_args += '/GR-'
1535 else
1536 cpp_args += '-fno-rtti'
1537 endif
1538 endif
1539 elif with_amd_vk or with_gallium_radeonsi or with_gallium_swr
1540 error('The following drivers require LLVM: Radv, RadeonSI, SWR. One of these is enabled, but LLVM is disabled.')
1541 elif with_gallium_opencl
1542 error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
1543 endif
1544
1545 if (with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or
1546 (with_gallium_r600 and with_llvm))
1547 dep_elf = dependency('libelf', required : false)
1548 if not dep_elf.found()
1549 dep_elf = cc.find_library('elf')
1550 endif
1551 else
1552 dep_elf = null_dep
1553 endif
1554
1555 dep_glvnd = null_dep
1556 if with_glvnd
1557 dep_glvnd = dependency('libglvnd', version : '>= 1.2.0')
1558 pre_args += '-DUSE_LIBGLVND=1'
1559 endif
1560
1561 _valgrind = get_option('valgrind')
1562 if _valgrind == 'true'
1563 _valgrind = 'enabled'
1564 warning('valgrind option "true" deprecated, please use "enabled" instead.')
1565 elif _valgrind == 'false'
1566 _valgrind = 'disabled'
1567 warning('valgrind option "false" deprecated, please use "disabled" instead.')
1568 endif
1569 if _valgrind != 'disabled'
1570 dep_valgrind = dependency('valgrind', required : _valgrind == 'enabled')
1571 if dep_valgrind.found()
1572 pre_args += '-DHAVE_VALGRIND'
1573 endif
1574 else
1575 dep_valgrind = null_dep
1576 endif
1577
1578 # pthread stubs. Lets not and say we didn't
1579
1580 if host_machine.system() == 'windows'
1581 # Prefer the winflexbison versions, they're much easier to install and have
1582 # better windows support.
1583
1584 prog_flex = find_program('win_flex', required : false)
1585 if prog_flex.found()
1586 # windows compatibility (uses <io.h> instead of <unistd.h> and _isatty,
1587 # _fileno functions)
1588 prog_flex = [prog_flex, '--wincompat', '-D__STDC_VERSION__=199901']
1589 else
1590 prog_flex = [find_program('lex', 'flex', required : with_any_opengl)]
1591 endif
1592 # Force flex to use const keyword in prototypes, as relies on __cplusplus or
1593 # __STDC__ macro to determine whether it's safe to use const keyword, but
1594 # MSVC never defines __STDC__ unless we disable all MSVC extensions.
1595 prog_flex += '-DYY_USE_CONST='
1596
1597 prog_bison = find_program('win_bison', required : false)
1598 if not prog_bison.found()
1599 prog_bison = find_program('yacc', 'bison', required : with_any_opengl)
1600 endif
1601 else
1602 prog_bison = find_program('bison', required : with_any_opengl)
1603
1604 # Disable deprecated keyword warnings, since we have to use them for
1605 # old-bison compat. See discussion in
1606 # https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2161
1607 if find_program('bison', required : false, version : '> 2.3').found()
1608 prog_bison = [prog_bison, '-Wno-deprecated']
1609 endif
1610
1611 prog_flex = find_program('flex', required : with_any_opengl)
1612 endif
1613
1614 dep_selinux = null_dep
1615 if get_option('selinux')
1616 dep_selinux = dependency('libselinux')
1617 pre_args += '-DMESA_SELINUX'
1618 endif
1619
1620 _libunwind = get_option('libunwind')
1621 if _libunwind == 'true'
1622 _libunwind = 'enabled'
1623 warning('libunwind option "true" deprecated, please use "enabled" instead.')
1624 elif _libunwind == 'false'
1625 _libunwind = 'disabled'
1626 warning('libunwind option "false" deprecated, please use "disabled" instead.')
1627 endif
1628 if _libunwind != 'disabled'
1629 dep_unwind = dependency('libunwind', required : _libunwind == 'enabled')
1630 if dep_unwind.found()
1631 pre_args += '-DHAVE_LIBUNWIND'
1632 endif
1633 else
1634 dep_unwind = null_dep
1635 endif
1636
1637 if with_osmesa != 'none'
1638 if with_osmesa == 'gallium' and not with_gallium_softpipe
1639 error('OSMesa gallium requires gallium softpipe or llvmpipe.')
1640 endif
1641 if host_machine.system() == 'windows'
1642 osmesa_lib_name = 'osmesa'
1643 else
1644 osmesa_lib_name = 'OSMesa'
1645 endif
1646 osmesa_bits = get_option('osmesa-bits')
1647 if osmesa_bits != '8'
1648 if with_dri or with_glx != 'disabled'
1649 error('OSMesa bits must be 8 if building glx or dir based drivers')
1650 endif
1651 osmesa_lib_name = osmesa_lib_name + osmesa_bits
1652 pre_args += [
1653 '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
1654 ]
1655 endif
1656 endif
1657
1658 # TODO: symbol mangling
1659
1660 if with_platform_wayland
1661 dep_wl_scanner = dependency('wayland-scanner', native: true)
1662 prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner'))
1663 if dep_wl_scanner.version().version_compare('>= 1.15')
1664 wl_scanner_arg = 'private-code'
1665 else
1666 wl_scanner_arg = 'code'
1667 endif
1668 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
1669 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
1670 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
1671 if with_egl
1672 dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3')
1673 dep_wayland_egl_headers = dep_wayland_egl.partial_dependency(compile_args : true)
1674 endif
1675 wayland_dmabuf_xml = join_paths(
1676 dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
1677 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
1678 )
1679 pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
1680 endif
1681
1682 dep_x11 = null_dep
1683 dep_xext = null_dep
1684 dep_xdamage = null_dep
1685 dep_xfixes = null_dep
1686 dep_x11_xcb = null_dep
1687 dep_xcb = null_dep
1688 dep_xcb_glx = null_dep
1689 dep_xcb_dri2 = null_dep
1690 dep_xcb_dri3 = null_dep
1691 dep_dri2proto = null_dep
1692 dep_glproto = null_dep
1693 dep_xxf86vm = null_dep
1694 dep_xcb_dri3 = null_dep
1695 dep_xcb_present = null_dep
1696 dep_xcb_sync = null_dep
1697 dep_xcb_xfixes = null_dep
1698 dep_xshmfence = null_dep
1699 dep_xcb_xrandr = null_dep
1700 dep_xlib_xrandr = null_dep
1701 if with_platform_x11
1702 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
1703 dep_x11 = dependency('x11')
1704 dep_xext = dependency('xext')
1705 dep_xcb = dependency('xcb')
1706 elif with_glx == 'dri'
1707 dep_x11 = dependency('x11')
1708 dep_xext = dependency('xext')
1709 dep_xdamage = dependency('xdamage', version : '>= 1.1')
1710 dep_xfixes = dependency('xfixes')
1711 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
1712 endif
1713 if (with_any_vk or with_glx == 'dri' or with_egl or
1714 (with_gallium_vdpau or with_gallium_xvmc or with_gallium_va or
1715 with_gallium_omx != 'disabled'))
1716 dep_xcb = dependency('xcb')
1717 dep_x11_xcb = dependency('x11-xcb')
1718 if with_dri_platform == 'drm' and not dep_libdrm.found()
1719 error('libdrm required for gallium video statetrackers when using x11')
1720 endif
1721 endif
1722 if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
1723 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
1724
1725 if with_dri3
1726 pre_args += '-DHAVE_DRI3'
1727 dep_xcb_dri3 = dependency('xcb-dri3')
1728 dep_xcb_present = dependency('xcb-present')
1729 # until xcb-dri3 has been around long enough to make a hard-dependency:
1730 if (dep_xcb_dri3.version().version_compare('>= 1.13') and
1731 dep_xcb_present.version().version_compare('>= 1.13'))
1732 pre_args += '-DHAVE_DRI3_MODIFIERS'
1733 endif
1734 dep_xcb_sync = dependency('xcb-sync')
1735 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
1736 endif
1737 endif
1738 if with_glx == 'dri' or with_glx == 'gallium-xlib'
1739 dep_glproto = dependency('glproto', version : '>= 1.4.14')
1740 endif
1741 if with_glx == 'dri'
1742 if with_dri_platform == 'drm'
1743 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
1744 dep_xxf86vm = dependency('xxf86vm')
1745 endif
1746 endif
1747 if (with_egl or (
1748 with_gallium_vdpau or with_gallium_xvmc or with_gallium_xa or
1749 with_gallium_omx != 'disabled'))
1750 dep_xcb_xfixes = dependency('xcb-xfixes')
1751 endif
1752 if with_xlib_lease
1753 dep_xcb_xrandr = dependency('xcb-randr')
1754 dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
1755 endif
1756 endif
1757
1758 if get_option('gallium-extra-hud')
1759 pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
1760 endif
1761
1762 _sensors = get_option('lmsensors')
1763 if _sensors == 'true'
1764 _sensors = 'enabled'
1765 warning('sensors option "true" deprecated, please use "enabled" instead.')
1766 elif _sensors == 'false'
1767 _sensors = 'disabled'
1768 warning('sensors option "false" deprecated, please use "disabled" instead.')
1769 endif
1770 if _sensors != 'disabled'
1771 dep_lmsensors = cc.find_library('sensors', required : _sensors == 'enabled')
1772 if dep_lmsensors.found()
1773 pre_args += '-DHAVE_LIBSENSORS=1'
1774 endif
1775 else
1776 dep_lmsensors = null_dep
1777 endif
1778
1779 foreach a : pre_args
1780 add_project_arguments(a, language : ['c', 'cpp'])
1781 endforeach
1782 foreach a : c_args
1783 add_project_arguments(a, language : ['c'])
1784 endforeach
1785 foreach a : cpp_args
1786 add_project_arguments(a, language : ['cpp'])
1787 endforeach
1788
1789 gl_priv_reqs = []
1790
1791 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
1792 gl_priv_reqs += ['x11', 'xext', 'xcb']
1793 elif with_glx == 'dri'
1794 gl_priv_reqs += [
1795 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
1796 'xcb-glx >= 1.8.1']
1797 if with_dri_platform == 'drm'
1798 gl_priv_reqs += 'xcb-dri2 >= 1.8'
1799 gl_priv_reqs += 'xxf86vm'
1800 endif
1801 endif
1802 if dep_libdrm.found()
1803 gl_priv_reqs += 'libdrm >= 2.4.75'
1804 endif
1805
1806 gl_priv_libs = []
1807 if dep_thread.found()
1808 gl_priv_libs += ['-lpthread', '-pthread']
1809 endif
1810 if dep_m.found()
1811 gl_priv_libs += '-lm'
1812 endif
1813 if dep_dl.found()
1814 gl_priv_libs += '-ldl'
1815 endif
1816
1817 pkg = import('pkgconfig')
1818
1819 if host_machine.system() == 'windows'
1820 prog_dumpbin = find_program('dumpbin', required : false)
1821 with_symbols_check = prog_dumpbin.found() and with_tests
1822 symbols_check_args = ['--dumpbin', prog_dumpbin.path()]
1823 else
1824 prog_nm = find_program('nm')
1825 with_symbols_check = with_tests
1826 symbols_check_args = ['--nm', prog_nm.path()]
1827 endif
1828
1829 # This quirk needs to be applied to sources with functions defined in assembly
1830 # as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391
1831 gcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : []
1832
1833 subdir('include')
1834 subdir('bin')
1835 subdir('src')
1836
1837 # Meson 0.49 and earlier seems to have a bug that fails to evaluate the string-
1838 # formatting below unless the first argument is passed as a variable. This has
1839 # been fixed in Meson 0.50 and beyond, but we need to keep it like this for now
1840 # for backwards compatibility.
1841 _with_opengl_string = with_opengl ? 'yes' : 'no'
1842
1843 lines = ['',
1844 'prefix: ' + get_option('prefix'),
1845 'libdir: ' + get_option('libdir'),
1846 'includedir: ' + get_option('includedir'),
1847 '',
1848 'OpenGL: @0@ (ES1: @1@ ES2: @2@)'.format(_with_opengl_string,
1849 with_gles1 ? 'yes' : 'no',
1850 with_gles2 ? 'yes' : 'no'),
1851 ]
1852
1853 if with_osmesa != 'none'
1854 lines += ''
1855 suffix = ''
1856 if with_osmesa == 'gallium'
1857 suffix = '(Gallium)'
1858 endif
1859 lines += 'OSMesa: lib' + osmesa_lib_name + suffix
1860 else
1861 lines += 'OSMesa: no'
1862 endif
1863
1864 if with_dri
1865 lines += ''
1866 lines += 'DRI platform: ' + with_dri_platform
1867 if dri_drivers.length() != 0 and dri_drivers != ['']
1868 lines += 'DRI drivers: ' + ' '.join(dri_drivers)
1869 else
1870 lines += 'DRI drivers: no'
1871 endif
1872 lines += 'DRI driver dir: ' + dri_drivers_path
1873 endif
1874
1875 if with_glx != 'disabled'
1876 lines += ''
1877 if with_glx == 'dri'
1878 lines += 'GLX: DRI-based'
1879 elif with_glx == 'xlib'
1880 lines += 'GLX: Xlib-based'
1881 elif with_glx == 'gallium-xlib'
1882 lines += 'GLX: Xlib-based (Gallium)'
1883 else
1884 lines += 'GLX: ' + with_glx
1885 endif
1886 endif
1887
1888 lines += ''
1889 lines += 'EGL: ' + (with_egl ? 'yes' : 'no')
1890 if with_egl
1891 egl_drivers = []
1892 if with_dri
1893 egl_drivers += 'builtin:egl_dri2'
1894 endif
1895 if with_dri3
1896 egl_drivers += 'builtin:egl_dri3'
1897 endif
1898 lines += 'EGL drivers: ' + ' '.join(egl_drivers)
1899 endif
1900 lines += 'GBM: ' + (with_gbm ? 'yes' : 'no')
1901 if with_platforms
1902 lines += 'EGL/Vulkan/VL platforms: ' + ' '.join(_platforms)
1903 endif
1904
1905 lines += ''
1906 if with_any_vk
1907 lines += 'Vulkan drivers: ' + ' '.join(_vulkan_drivers)
1908 lines += 'Vulkan ICD dir: ' + with_vulkan_icd_dir
1909 else
1910 lines += 'Vulkan drivers: no'
1911 endif
1912
1913 lines += ''
1914 if with_llvm
1915 lines += 'llvm: yes'
1916 lines += 'llvm-version: ' + dep_llvm.version()
1917 else
1918 lines += 'llvm: no'
1919 endif
1920
1921 lines += ''
1922 if with_gallium
1923 lines += 'Gallium drivers: ' + ' '.join(gallium_drivers)
1924 gallium_st = ['mesa']
1925 if with_gallium_xa
1926 gallium_st += 'xa'
1927 endif
1928 if with_gallium_xvmc
1929 gallium_st += 'xvmc'
1930 endif
1931 if with_gallium_xvmc
1932 gallium_st += 'xvmc'
1933 endif
1934 if with_gallium_vdpau
1935 gallium_st += 'vdpau'
1936 endif
1937 if with_gallium_omx != 'disabled'
1938 gallium_st += 'omx' + with_gallium_omx
1939 endif
1940 if with_gallium_va
1941 gallium_st += 'va'
1942 endif
1943 if with_gallium_st_nine
1944 gallium_st += 'nine'
1945 endif
1946 if with_gallium_opencl
1947 gallium_st += 'clover'
1948 endif
1949 lines += 'Gallium st: ' + ' '.join(gallium_st)
1950 else
1951 lines += 'Gallium: no'
1952 endif
1953
1954 lines += 'HUD lmsensors: ' + (dep_lmsensors.found() ? 'yes' : 'no')
1955
1956 lines += ''
1957 lines += 'Shared-glapi: ' + (with_shared_glapi ? 'yes' : 'no')
1958
1959
1960 indent = ' '
1961 summary = indent + ('\n' + indent).join(lines)
1962 message('Configuration summary:\n@0@\n'.format(summary))