VirtualBox

source: vbox/trunk/src/VBox/Additions/3D/mesa/mesa-21.3.8/meson.build@ 104894

最後變更 在這個檔案從104894是 96488,由 vboxsync 提交於 2 年 前

Additions/3D/mesa: Export to OSE and remove symlinks.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette