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