1# Copyright © 2017-2019 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('python', 'python2', 'python3'), 'bin/meson_get_version.py'] 26 ).stdout(), 27 license : 'MIT', 28 meson_version : '>= 0.45', 29 default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c99', 'cpp_std=c++11'] 30) 31 32cc = meson.get_compiler('c') 33cpp = meson.get_compiler('cpp') 34 35null_dep = dependency('', required : false) 36 37# Arguments for the preprocessor, put these in a separate array from the C and 38# C++ (cpp in meson terminology) arguments since they need to be added to the 39# default arguments for both C and C++. 40pre_args = [ 41 '-D__STDC_CONSTANT_MACROS', 42 '-D__STDC_FORMAT_MACROS', 43 '-D__STDC_LIMIT_MACROS', 44 '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()), 45 '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"', 46] 47 48with_vulkan_icd_dir = get_option('vulkan-icd-dir') 49with_tests = get_option('build-tests') 50with_valgrind = get_option('valgrind') 51with_libunwind = get_option('libunwind') 52with_asm = get_option('asm') 53with_glx_read_only_text = get_option('glx-read-only-text') 54with_glx_direct = get_option('glx-direct') 55with_osmesa = get_option('osmesa') 56with_swr_arches = get_option('swr-arches') 57with_tools = get_option('tools') 58if with_tools.contains('all') 59 with_tools = ['etnaviv', 'freedreno', 'glsl', 'intel', 'nir', 'nouveau', 'xvmc'] 60endif 61 62dri_drivers_path = get_option('dri-drivers-path') 63if dri_drivers_path == '' 64 dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri') 65endif 66dri_search_path = get_option('dri-search-path') 67if dri_search_path == '' 68 dri_search_path = dri_drivers_path 69endif 70 71with_gles1 = get_option('gles1') 72with_gles2 = get_option('gles2') 73if host_machine.system() == 'windows' 74 if with_gles1 == 'auto' 75 with_gles1 = 'false' 76 endif 77 if with_gles2 == 'auto' 78 with_gles2 = 'false' 79 endif 80endif 81with_opengl = get_option('opengl') 82with_shared_glapi = get_option('shared-glapi') 83 84# shared-glapi is required if at least two OpenGL APIs are being built 85if not with_shared_glapi 86 if ((with_gles1 == 'true' and with_gles2 == 'true') or 87 (with_gles1 == 'true' and with_opengl) or 88 (with_gles2 == 'true' and with_opengl)) 89 error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x') 90 endif 91 with_gles1 = 'false' 92 with_gles2 = 'false' 93endif 94 95# We require OpenGL for OpenGL ES 96if not with_opengl 97 if (with_gles1 == 'true' or with_gles2 == 'true') and not with_opengl 98 error('building OpenGL ES without OpenGL is not supported.') 99 endif 100 with_gles1 = 'false' 101 with_gles2 = 'false' 102endif 103 104with_gles1 = with_gles1 != 'false' 105with_gles2 = with_gles2 != 'false' 106with_any_opengl = with_opengl or with_gles1 or with_gles2 107# Only build shared_glapi if at least one OpenGL API is enabled 108with_shared_glapi = get_option('shared-glapi') and with_any_opengl 109 110system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux'].contains(host_machine.system()) 111 112dri_drivers = get_option('dri-drivers') 113if dri_drivers.contains('auto') 114 if system_has_kms_drm 115 # TODO: PPC, Sparc 116 if ['x86', 'x86_64'].contains(host_machine.cpu_family()) 117 dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau'] 118 elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 119 dri_drivers = [] 120 else 121 error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format( 122 host_machine.cpu_family())) 123 endif 124 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) 125 # only swrast would make sense here, but gallium swrast is a much better default 126 dri_drivers = [] 127 else 128 error('Unknown OS @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format( 129 host_machine.system())) 130 endif 131endif 132 133with_dri_i915 = dri_drivers.contains('i915') 134with_dri_i965 = dri_drivers.contains('i965') 135with_dri_r100 = dri_drivers.contains('r100') 136with_dri_r200 = dri_drivers.contains('r200') 137with_dri_nouveau = dri_drivers.contains('nouveau') 138with_dri_swrast = dri_drivers.contains('swrast') 139 140with_dri = dri_drivers.length() != 0 and dri_drivers != [''] 141 142gallium_drivers = get_option('gallium-drivers') 143if gallium_drivers.contains('auto') 144 if system_has_kms_drm 145 # TODO: PPC, Sparc 146 if ['x86', 'x86_64'].contains(host_machine.cpu_family()) 147 gallium_drivers = [ 148 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast' 149 ] 150 elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 151 gallium_drivers = [ 152 'kmsro', 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau', 153 'tegra', 'virgl', 'lima', 'swrast' 154 ] 155 else 156 error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format( 157 host_machine.cpu_family())) 158 endif 159 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) 160 gallium_drivers = ['swrast'] 161 else 162 error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format( 163 host_machine.system())) 164 endif 165endif 166with_gallium_kmsro = gallium_drivers.contains('kmsro') 167with_gallium_radeonsi = gallium_drivers.contains('radeonsi') 168with_gallium_r300 = gallium_drivers.contains('r300') 169with_gallium_r600 = gallium_drivers.contains('r600') 170with_gallium_nouveau = gallium_drivers.contains('nouveau') 171with_gallium_freedreno = gallium_drivers.contains('freedreno') 172with_gallium_softpipe = gallium_drivers.contains('swrast') 173with_gallium_vc4 = gallium_drivers.contains('vc4') 174with_gallium_v3d = gallium_drivers.contains('v3d') 175with_gallium_panfrost = gallium_drivers.contains('panfrost') 176with_gallium_etnaviv = gallium_drivers.contains('etnaviv') 177with_gallium_tegra = gallium_drivers.contains('tegra') 178with_gallium_iris = gallium_drivers.contains('iris') 179with_gallium_i915 = gallium_drivers.contains('i915') 180with_gallium_svga = gallium_drivers.contains('svga') 181with_gallium_virgl = gallium_drivers.contains('virgl') 182with_gallium_swr = gallium_drivers.contains('swr') 183with_gallium_lima = gallium_drivers.contains('lima') 184 185if cc.get_id() == 'intel' 186 if meson.version().version_compare('< 0.49.0') 187 error('Meson does not have sufficient support of ICC before 0.49.0 to compile mesa') 188 elif with_gallium_swr and meson.version().version_compare('== 0.49.0') 189 warning('Meson as of 0.49.0 is sufficient for compiling mesa with ICC, but there are some caveats with SWR. 0.49.1 should resolve all of these') 190 endif 191endif 192 193#This message is needed until we bump meson version to 0.46 because of known 0.45.0 and 0.45.1 issue 194#https://bugs.freedesktop.org/show_bug.cgi?id=109791 195if meson.version().version_compare('< 0.46.0') 196 warning('''Meson < 0.46 doesn't automatically define `NDEBUG`; please update meson to at least 0.46.''') 197endif 198 199with_gallium = gallium_drivers.length() != 0 and gallium_drivers != [''] 200 201if with_gallium and system_has_kms_drm 202 _glx = get_option('glx') 203 _egl = get_option('egl') 204 if _glx == 'dri' or _egl == 'true' or (_glx == 'disabled' and _egl != 'false') 205 with_dri = true 206 endif 207endif 208 209_vulkan_drivers = get_option('vulkan-drivers') 210if _vulkan_drivers.contains('auto') 211 if system_has_kms_drm 212 if host_machine.cpu_family().startswith('x86') 213 _vulkan_drivers = ['amd', 'intel'] 214 elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 215 _vulkan_drivers = [] 216 else 217 error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format( 218 host_machine.cpu_family())) 219 endif 220 elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) 221 # No vulkan driver supports windows or macOS currently 222 _vulkan_drivers = [] 223 else 224 error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format( 225 host_machine.system())) 226 endif 227endif 228 229with_intel_vk = _vulkan_drivers.contains('intel') 230with_amd_vk = _vulkan_drivers.contains('amd') 231with_freedreno_vk = _vulkan_drivers.contains('freedreno') 232with_any_vk = _vulkan_drivers.length() != 0 and _vulkan_drivers != [''] 233 234if with_freedreno_vk and get_option('I-love-half-baked-turnips') != true 235 error('Cannot enable freedreno vulkan driver') 236endif 237 238if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr) 239 error('Only one swrast provider can be built') 240endif 241if with_dri_i915 and with_gallium_i915 242 error('Only one i915 provider can be built') 243endif 244if 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) 245 error('kmsro driver requires one or more renderonly drivers (vc4, etnaviv, freedreno, panfrost, lima)') 246endif 247if with_gallium_tegra and not with_gallium_nouveau 248 error('tegra driver requires nouveau driver') 249endif 250 251if host_machine.system() == 'darwin' 252 with_dri_platform = 'apple' 253 pre_args += '-DBUILDING_MESA' 254elif ['windows', 'cygwin'].contains(host_machine.system()) 255 with_dri_platform = 'windows' 256elif system_has_kms_drm 257 with_dri_platform = 'drm' 258else 259 # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should 260 # assert here that one of those cases has been met. 261 # FIXME: illumos ends up here as well 262 with_dri_platform = 'none' 263endif 264 265_platforms = get_option('platforms') 266if _platforms.contains('auto') 267 if system_has_kms_drm 268 _platforms = ['x11', 'wayland', 'drm', 'surfaceless'] 269 elif ['darwin', 'windows', 'cygwin'].contains(host_machine.system()) 270 _platforms = ['x11', 'surfaceless'] 271 elif ['haiku'].contains(host_machine.system()) 272 _platforms = ['haiku'] 273 else 274 error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format( 275 host_machine.system())) 276 endif 277endif 278 279with_platform_android = _platforms.contains('android') 280with_platform_x11 = _platforms.contains('x11') 281with_platform_wayland = _platforms.contains('wayland') 282with_platform_drm = _platforms.contains('drm') 283with_platform_haiku = _platforms.contains('haiku') 284with_platform_surfaceless = _platforms.contains('surfaceless') 285 286with_platforms = false 287if _platforms.length() != 0 and _platforms != [''] 288 with_platforms = true 289 egl_native_platform = _platforms[0] 290endif 291 292_xlib_lease = get_option('xlib-lease') 293if _xlib_lease == 'auto' 294 with_xlib_lease = with_platform_x11 and with_platform_drm 295else 296 with_xlib_lease = _xlib_lease == 'true' 297endif 298 299with_glx = get_option('glx') 300if with_glx == 'auto' 301 if with_dri 302 with_glx = 'dri' 303 elif with_platform_haiku 304 with_glx = 'disabled' 305 elif with_gallium 306 # Even when building just gallium drivers the user probably wants dri 307 with_glx = 'dri' 308 elif with_platform_x11 and with_any_opengl and not with_any_vk 309 # The automatic behavior should not be to turn on xlib based glx when 310 # building only vulkan drivers 311 with_glx = 'xlib' 312 else 313 with_glx = 'disabled' 314 endif 315endif 316if with_glx == 'dri' 317 if with_gallium 318 with_dri = true 319 endif 320endif 321 322if not (with_dri or with_gallium or with_glx != 'disabled') 323 with_gles1 = false 324 with_gles2 = false 325 with_opengl = false 326 with_any_opengl = false 327 with_shared_glapi = false 328endif 329 330_gbm = get_option('gbm') 331if _gbm == 'auto' 332 with_gbm = system_has_kms_drm and with_dri 333else 334 with_gbm = _gbm == 'true' 335endif 336if with_gbm and not system_has_kms_drm 337 error('GBM only supports DRM/KMS platforms') 338endif 339 340_egl = get_option('egl') 341if _egl == 'auto' 342 with_egl = ( 343 not ['darwin', 'windows'].contains(host_machine.system()) and 344 with_dri and with_shared_glapi and with_platforms 345 ) 346elif _egl == 'true' 347 if not with_dri 348 error('EGL requires dri') 349 elif not with_shared_glapi 350 error('EGL requires shared-glapi') 351 elif not with_platforms 352 error('No platforms specified, consider -Dplatforms=drm,x11,surfaceless at least') 353 elif not ['disabled', 'dri'].contains(with_glx) 354 error('EGL requires dri, but a GLX is being built without dri') 355 elif ['darwin', 'windows'].contains(host_machine.system()) 356 error('EGL is not available on Windows or MacOS') 357 endif 358 with_egl = true 359else 360 with_egl = false 361endif 362 363if with_egl and not (with_platform_drm or with_platform_surfaceless or with_platform_android) 364 if with_gallium_radeonsi 365 error('RadeonSI requires the drm, surfaceless or android platform when using EGL') 366 endif 367 if with_gallium_virgl 368 error('Virgl requires the drm, surfaceless or android platform when using EGL') 369 endif 370endif 371 372pre_args += '-DGLX_USE_TLS' 373if with_glx != 'disabled' 374 if not (with_platform_x11 and with_any_opengl) 375 error('Cannot build GLX support without X11 platform support and at least one OpenGL API') 376 elif with_glx == 'gallium-xlib' 377 if not with_gallium 378 error('Gallium-xlib based GLX requires at least one gallium driver') 379 elif not with_gallium_softpipe 380 error('Gallium-xlib based GLX requires softpipe or llvmpipe.') 381 elif with_dri 382 error('gallium-xlib conflicts with any dri driver') 383 endif 384 elif with_glx == 'xlib' 385 if with_dri 386 error('xlib conflicts with any dri driver') 387 endif 388 elif with_glx == 'dri' 389 if not with_shared_glapi 390 error('dri based GLX requires shared-glapi') 391 endif 392 endif 393endif 394 395with_glvnd = get_option('glvnd') 396if with_glvnd 397 if with_glx == 'xlib' or with_glx == 'gallium-xlib' 398 error('Cannot build glvnd support for GLX that is not DRI based.') 399 elif with_glx == 'disabled' and not with_egl 400 error('glvnd requires DRI based GLX and/or EGL') 401 endif 402 if get_option('egl-lib-suffix') != '' 403 error('''EGL lib suffix can't be used with libglvnd''') 404 endif 405endif 406 407if with_vulkan_icd_dir == '' 408 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d') 409endif 410 411with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or 412 host_machine.system() == 'gnu') 413_dri3 = get_option('dri3') 414if _dri3 == 'auto' 415 with_dri3 = system_has_kms_drm and with_dri2 416else 417 with_dri3 = _dri3 == 'true' 418endif 419 420if with_any_vk and (with_platform_x11 and not with_dri3) 421 error('Vulkan drivers require dri3 for X11 support') 422endif 423if with_dri 424 if with_glx == 'disabled' and not with_egl and not with_gbm and with_osmesa != 'classic' 425 error('building dri drivers require at least one windowing system or classic osmesa') 426 endif 427endif 428 429prog_pkgconfig = find_program('pkg-config') 430 431_vdpau = get_option('gallium-vdpau') 432if not system_has_kms_drm 433 if _vdpau == 'true' 434 error('VDPAU state tracker can only be build on unix-like OSes.') 435 else 436 _vdpau = 'false' 437 endif 438elif not with_platform_x11 439 if _vdpau == 'true' 440 error('VDPAU state tracker requires X11 support.') 441 else 442 _vdpau = 'false' 443 endif 444elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or 445 with_gallium_nouveau) 446 if _vdpau == 'true' 447 error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.') 448 else 449 _vdpau = 'false' 450 endif 451endif 452dep_vdpau = null_dep 453with_gallium_vdpau = false 454if _vdpau != 'false' 455 dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'true') 456 if dep_vdpau.found() 457 dep_vdpau = declare_dependency( 458 compile_args : run_command(prog_pkgconfig, ['vdpau', '--cflags']).stdout().split() 459 ) 460 with_gallium_vdpau = true 461 endif 462endif 463 464if with_gallium_vdpau 465 pre_args += '-DHAVE_ST_VDPAU' 466endif 467vdpau_drivers_path = get_option('vdpau-libs-path') 468if vdpau_drivers_path == '' 469 vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau') 470endif 471 472_xvmc = get_option('gallium-xvmc') 473if not system_has_kms_drm 474 if _xvmc == 'true' 475 error('XVMC state tracker can only be build on unix-like OSes.') 476 else 477 _xvmc = 'false' 478 endif 479elif not with_platform_x11 480 if _xvmc == 'true' 481 error('XVMC state tracker requires X11 support.') 482 else 483 _xvmc = 'false' 484 endif 485elif not (with_gallium_r600 or with_gallium_nouveau) 486 if _xvmc == 'true' 487 error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.') 488 else 489 _xvmc = 'false' 490 endif 491endif 492dep_xvmc = null_dep 493with_gallium_xvmc = false 494if _xvmc != 'false' 495 dep_xvmc = dependency('xvmc', version : '>= 1.0.6', required : _xvmc == 'true') 496 with_gallium_xvmc = dep_xvmc.found() 497endif 498 499xvmc_drivers_path = get_option('xvmc-libs-path') 500if xvmc_drivers_path == '' 501 xvmc_drivers_path = get_option('libdir') 502endif 503 504_omx = get_option('gallium-omx') 505if not system_has_kms_drm 506 if ['auto', 'disabled'].contains(_omx) 507 _omx = 'disabled' 508 else 509 error('OMX state tracker can only be built on unix-like OSes.') 510 endif 511elif not (with_platform_x11 or with_platform_drm) 512 if ['auto', 'disabled'].contains(_omx) 513 _omx = 'disabled' 514 else 515 error('OMX state tracker requires X11 or drm platform support.') 516 endif 517elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau) 518 if ['auto', 'disabled'].contains(_omx) 519 _omx = 'disabled' 520 else 521 error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.') 522 endif 523endif 524with_gallium_omx = _omx 525dep_omx = null_dep 526dep_omx_other = [] 527if ['auto', 'bellagio'].contains(_omx) 528 dep_omx = dependency( 529 'libomxil-bellagio', required : _omx == 'bellagio' 530 ) 531 if dep_omx.found() 532 with_gallium_omx = 'bellagio' 533 endif 534endif 535if ['auto', 'tizonia'].contains(_omx) 536 if with_dri and with_egl 537 dep_omx = dependency( 538 'libtizonia', version : '>= 0.10.0', 539 required : _omx == 'tizonia', 540 ) 541 dep_omx_other = [ 542 dependency('libtizplatform', required : _omx == 'tizonia'), 543 dependency('tizilheaders', required : _omx == 'tizonia'), 544 ] 545 if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found() 546 with_gallium_omx = 'tizonia' 547 endif 548 elif _omx == 'tizonia' 549 error('OMX-Tizonia state tracker requires dri and egl') 550 endif 551endif 552if _omx == 'auto' 553 with_gallium_omx = 'disabled' 554else 555 with_gallium_omx = _omx 556endif 557 558pre_args += [ 559 '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'), 560 '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'), 561] 562 563 564omx_drivers_path = get_option('omx-libs-path') 565 566if with_gallium_omx != 'disabled' 567 # Figure out where to put the omx driver. 568 # FIXME: this could all be vastly simplified by adding a 'defined_variable' 569 # argument to meson's get_pkgconfig_variable method. 570 if omx_drivers_path == '' 571 _omx_libdir = dep_omx.get_pkgconfig_variable('libdir') 572 _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir') 573 if _omx_libdir == get_option('libdir') 574 omx_drivers_path = _omx_drivers_dir 575 else 576 _omx_base_dir = [] 577 # This will fail on windows. Does OMX run on windows? 578 _omx_libdir = _omx_libdir.split('/') 579 _omx_drivers_dir = _omx_drivers_dir.split('/') 580 foreach o : _omx_drivers_dir 581 if not _omx_libdir.contains(o) 582 _omx_base_dir += o 583 endif 584 endforeach 585 omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir) 586 endif 587 endif 588endif 589 590_va = get_option('gallium-va') 591if not system_has_kms_drm 592 if _va == 'true' 593 error('VA state tracker can only be built on unix-like OSes.') 594 else 595 _va = 'false' 596 endif 597elif not (with_platform_x11 or with_platform_drm) 598 if _va == 'true' 599 error('VA state tracker requires X11 or drm or wayland platform support.') 600 else 601 _va = 'false' 602 endif 603elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau) 604 if _va == 'true' 605 error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.') 606 else 607 _va = 'false' 608 endif 609endif 610with_gallium_va = false 611dep_va = null_dep 612if _va != 'false' 613 dep_va = dependency('libva', version : '>= 0.38.0', required : _va == 'true') 614 if dep_va.found() 615 dep_va_headers = declare_dependency( 616 compile_args : run_command(prog_pkgconfig, ['libva', '--cflags']).stdout().split() 617 ) 618 with_gallium_va = true 619 endif 620endif 621 622va_drivers_path = get_option('va-libs-path') 623if va_drivers_path == '' 624 va_drivers_path = join_paths(get_option('libdir'), 'dri') 625endif 626 627_xa = get_option('gallium-xa') 628if not system_has_kms_drm 629 if _xa == 'true' 630 error('XA state tracker can only be built on unix-like OSes.') 631 else 632 _xa = 'false' 633 endif 634elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915 635 or with_gallium_svga) 636 if _xa == 'true' 637 error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.') 638 else 639 _xa = 'false' 640 endif 641endif 642with_gallium_xa = _xa != 'false' 643 644d3d_drivers_path = get_option('d3d-drivers-path') 645if d3d_drivers_path == '' 646 d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d') 647endif 648 649with_gallium_st_nine = get_option('gallium-nine') 650if with_gallium_st_nine 651 if not with_gallium_softpipe 652 error('The nine state tracker requires gallium softpipe/llvmpipe.') 653 elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600 654 or with_gallium_r300 or with_gallium_svga or with_gallium_i915 655 or with_gallium_iris) 656 error('The nine state tracker requires at least one non-swrast gallium driver.') 657 endif 658 if not with_dri3 659 error('Using nine with wine requires dri3') 660 endif 661endif 662 663if get_option('power8') != 'false' 664 # on old versions of meson the cpu family would return as ppc64le on little 665 # endian power8, this was changed in 0.48 such that the family would always 666 # be ppc64 regardless of endianness, and the the machine.endian() value 667 # should be checked. Since we support versions < 0.48 we need to use 668 # startswith. 669 if host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little' 670 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8') 671 error('Altivec is not supported with gcc version < 4.8.') 672 endif 673 if cc.compiles(''' 674 #include <altivec.h> 675 int main() { 676 vector unsigned char r; 677 vector unsigned int v = vec_splat_u32 (1); 678 r = __builtin_vec_vgbbd ((vector unsigned char) v); 679 return 0; 680 }''', 681 args : '-mpower8-vector', 682 name : 'POWER8 intrinsics') 683 pre_args += ['-D_ARCH_PWR8', '-mpower8-vector'] 684 elif get_option('power8') == 'true' 685 error('POWER8 intrinsic support required but not found.') 686 endif 687 endif 688endif 689 690_opencl = get_option('gallium-opencl') 691clover_cpp_std = [] 692if _opencl != 'disabled' 693 if not with_gallium 694 error('OpenCL Clover implementation requires at least one gallium driver.') 695 endif 696 697 dep_clc = dependency('libclc') 698 with_gallium_opencl = true 699 with_opencl_icd = _opencl == 'icd' 700 701 if host_machine.cpu_family().startswith('ppc') and cpp.compiles(''' 702 #if !defined(__VEC__) || !defined(__ALTIVEC__) 703 #error "AltiVec not enabled" 704 #endif''', 705 name : 'Altivec') 706 clover_cpp_std += ['cpp_std=gnu++11'] 707 endif 708else 709 dep_clc = null_dep 710 with_gallium_opencl = false 711 with_opencl_icd = false 712endif 713 714gl_pkgconfig_c_flags = [] 715if with_platform_x11 716 if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm') 717 pre_args += '-DHAVE_X11_PLATFORM' 718 endif 719 if with_glx == 'xlib' or with_glx == 'gallium-xlib' 720 pre_args += '-DUSE_XSHM' 721 else 722 pre_args += '-DGLX_INDIRECT_RENDERING' 723 if with_glx_direct 724 pre_args += '-DGLX_DIRECT_RENDERING' 725 endif 726 if with_dri_platform == 'drm' 727 pre_args += '-DGLX_USE_DRM' 728 elif with_dri_platform == 'apple' 729 pre_args += '-DGLX_USE_APPLEGL' 730 elif with_dri_platform == 'windows' 731 pre_args += '-DGLX_USE_WINDOWSGL' 732 endif 733 endif 734else 735 pre_args += '-DMESA_EGL_NO_X11_HEADERS' 736 gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS' 737endif 738if with_platform_drm 739 if with_egl and not with_gbm 740 error('EGL drm platform requires gbm') 741 endif 742 pre_args += '-DHAVE_DRM_PLATFORM' 743endif 744if with_platform_surfaceless 745 pre_args += '-DHAVE_SURFACELESS_PLATFORM' 746endif 747if with_platform_android 748 dep_android = [ 749 dependency('cutils'), 750 dependency('hardware'), 751 dependency('sync'), 752 ] 753 if get_option('platform-sdk-version') >= 26 754 dep_android += dependency('nativewindow') 755 endif 756 pre_args += '-DHAVE_ANDROID_PLATFORM' 757endif 758if with_platform_haiku 759 pre_args += '-DHAVE_HAIKU_PLATFORM' 760endif 761 762if meson.version().version_compare('>=0.50') 763 prog_python = import('python').find_installation('python3') 764else 765 prog_python = import('python3').find_python() 766endif 767has_mako = run_command( 768 prog_python, '-c', 769 ''' 770from distutils.version import StrictVersion 771import mako 772assert StrictVersion(mako.__version__) > StrictVersion("0.8.0") 773 ''') 774if has_mako.returncode() != 0 775 error('Python (3.x) mako module >= 0.8.0 required to build mesa.') 776endif 777 778if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6') 779 error('When using GCC, version 4.4.6 or later is required.') 780endif 781 782# Define DEBUG for debug builds only (debugoptimized is not included on this one) 783if get_option('buildtype') == 'debug' 784 pre_args += '-DDEBUG' 785endif 786 787with_shader_cache = false 788_shader_cache = get_option('shader-cache') 789if _shader_cache != 'false' 790 if host_machine.system() == 'windows' 791 if _shader_cache == 'true' 792 error('Shader Cache does not currently work on Windows') 793 endif 794 else 795 pre_args += '-DENABLE_SHADER_CACHE' 796 with_shader_cache = true 797 endif 798endif 799if with_amd_vk and not with_shader_cache 800 error('Radv requires shader cache support') 801endif 802 803# Check for GCC style builtins 804foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs', 805 'ffsll', 'popcount', 'popcountll', 'unreachable'] 806 if cc.has_function(b) 807 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper()) 808 endif 809endforeach 810 811# check for GCC __attribute__ 812foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused', 813 'warn_unused_result', 'weak',] 814 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a), 815 name : '__attribute__((@0@))'.format(a)) 816 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper()) 817 endif 818endforeach 819if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));', 820 name : '__attribute__((format(...)))') 821 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT' 822endif 823if cc.compiles('struct __attribute__((packed)) foo { int bar; };', 824 name : '__attribute__((packed))') 825 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED' 826endif 827if cc.compiles('int *foo(void) __attribute__((returns_nonnull));', 828 name : '__attribute__((returns_nonnull))') 829 pre_args += '-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL' 830endif 831if cc.compiles('''int foo_def(void) __attribute__((visibility("default"))); 832 int foo_hid(void) __attribute__((visibility("hidden"))); 833 int foo_int(void) __attribute__((visibility("internal"))); 834 int foo_pro(void) __attribute__((visibility("protected")));''', 835 name : '__attribute__((visibility(...)))') 836 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY' 837endif 838if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));', 839 name : '__attribute__((alias(...)))') 840 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS' 841endif 842if cc.compiles('int foo(void) __attribute__((__noreturn__));', 843 name : '__attribute__((__noreturn__))') 844 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NORETURN' 845endif 846 847# TODO: this is very incomplete 848if ['linux', 'cygwin', 'gnu', 'gnu/kfreebsd'].contains(host_machine.system()) 849 pre_args += '-D_GNU_SOURCE' 850endif 851 852# Check for generic C arguments 853c_args = [] 854foreach a : ['-Werror=implicit-function-declaration', 855 '-Werror=missing-prototypes', '-Werror=return-type', 856 '-Werror=incompatible-pointer-types', 857 '-fno-math-errno', 858 '-fno-trapping-math', '-Qunused-arguments'] 859 if cc.has_argument(a) 860 c_args += a 861 endif 862endforeach 863 864foreach a : ['missing-field-initializers', 'format-truncation'] 865 if cc.has_argument('-W' + a) 866 c_args += '-Wno-' + a 867 endif 868endforeach 869 870c_vis_args = [] 871if cc.has_argument('-fvisibility=hidden') 872 c_vis_args += '-fvisibility=hidden' 873endif 874 875# Check for generic C++ arguments 876cpp_args = [] 877foreach a : ['-Werror=return-type', 878 '-fno-math-errno', '-fno-trapping-math', 879 '-Qunused-arguments'] 880 if cpp.has_argument(a) 881 cpp_args += a 882 endif 883endforeach 884 885# For some reason, the test for -Wno-foo always succeeds with gcc, even if the 886# option is not supported. Hence, check for -Wfoo instead. 887 888foreach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation'] 889 if cpp.has_argument('-W' + a) 890 cpp_args += '-Wno-' + a 891 endif 892endforeach 893 894no_override_init_args = [] 895foreach a : ['override-init', 'initializer-overrides'] 896 if cc.has_argument('-W' + a) 897 no_override_init_args += '-Wno-' + a 898 endif 899endforeach 900 901cpp_vis_args = [] 902if cpp.has_argument('-fvisibility=hidden') 903 cpp_vis_args += '-fvisibility=hidden' 904endif 905 906# Check for C and C++ arguments for MSVC2013 compatibility. These are only used 907# in parts of the mesa code base that need to compile with old versions of 908# MSVC, mainly common code 909c_msvc_compat_args = [] 910cpp_msvc_compat_args = [] 911foreach a : ['-Werror=pointer-arith', '-Werror=vla'] 912 if cc.has_argument(a) 913 c_msvc_compat_args += a 914 endif 915 if cpp.has_argument(a) 916 cpp_msvc_compat_args += a 917 endif 918endforeach 919 920if host_machine.cpu_family().startswith('x86') 921 pre_args += '-DUSE_SSE41' 922 with_sse41 = true 923 sse41_args = ['-msse4.1'] 924 925 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but 926 # that's not guaranteed 927 if host_machine.cpu_family() == 'x86' 928 sse41_args += '-mstackrealign' 929 endif 930else 931 with_sse41 = false 932 sse41_args = [] 933endif 934 935# Check for GCC style atomics 936dep_atomic = null_dep 937 938if cc.compiles('''#include <stdint.h> 939 int main() { 940 struct { 941 uint64_t *v; 942 } x; 943 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & 944 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); 945 946 }''', 947 name : 'GCC atomic builtins') 948 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS' 949 950 # Not all atomic calls can be turned into lock-free instructions, in which 951 # GCC will make calls into the libatomic library. Check whether we need to 952 # link with -latomic. 953 # 954 # This can happen for 64-bit atomic operations on 32-bit architectures such 955 # as ARM. 956 if not cc.links('''#include <stdint.h> 957 int main() { 958 struct { 959 uint64_t *v; 960 } x; 961 return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & 962 (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); 963 }''', 964 name : 'GCC atomic builtins required -latomic') 965 dep_atomic = cc.find_library('atomic') 966 endif 967endif 968if not cc.links('''#include <stdint.h> 969 uint64_t v; 970 int main() { 971 return __sync_add_and_fetch(&v, (uint64_t)1); 972 }''', 973 dependencies : dep_atomic, 974 name : 'GCC 64bit atomics') 975 pre_args += '-DMISSING_64BIT_ATOMICS' 976endif 977 978# TODO: shared/static? Is this even worth doing? 979 980# When cross compiling we generally need to turn off the use of assembly, 981# because mesa's assembly relies on building an executable for the host system, 982# and running it to get information about struct sizes. There is at least one 983# case of cross compiling where we can use asm, and that's x86_64 -> x86 when 984# host OS == build OS, since in that case the build machine can run the host's 985# binaries. 986if with_asm and meson.is_cross_build() 987 if build_machine.system() != host_machine.system() 988 # TODO: It may be possible to do this with an exe_wrapper (like wine). 989 message('Cross compiling from one OS to another, disabling assembly.') 990 with_asm = false 991 elif not (build_machine.cpu_family().startswith('x86') and host_machine.cpu_family() == 'x86') 992 # FIXME: Gentoo always sets -m32 for x86_64 -> x86 builds, resulting in an 993 # x86 -> x86 cross compile. We use startswith rather than == to handle this 994 # case. 995 # TODO: There may be other cases where the 64 bit version of the 996 # architecture can run 32 bit binaries (aarch64 and armv7 for example) 997 message(''' 998 Cross compiling to different architectures, and the host cannot run 999 the build machine's binaries. Disabling assembly. 1000 ''') 1001 with_asm = false 1002 endif 1003endif 1004 1005with_asm_arch = '' 1006if with_asm 1007 if host_machine.cpu_family() == 'x86' 1008 if system_has_kms_drm or host_machine.system() == 'gnu' 1009 with_asm_arch = 'x86' 1010 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM', 1011 '-DUSE_SSE_ASM'] 1012 1013 if with_glx_read_only_text 1014 pre_args += ['-DGLX_X86_READONLY_TEXT'] 1015 endif 1016 endif 1017 elif host_machine.cpu_family() == 'x86_64' 1018 if system_has_kms_drm 1019 with_asm_arch = 'x86_64' 1020 pre_args += ['-DUSE_X86_64_ASM'] 1021 endif 1022 elif host_machine.cpu_family() == 'arm' 1023 if system_has_kms_drm 1024 with_asm_arch = 'arm' 1025 pre_args += ['-DUSE_ARM_ASM'] 1026 endif 1027 elif host_machine.cpu_family() == 'aarch64' 1028 if system_has_kms_drm 1029 with_asm_arch = 'aarch64' 1030 pre_args += ['-DUSE_AARCH64_ASM'] 1031 endif 1032 elif host_machine.cpu_family() == 'sparc64' 1033 if system_has_kms_drm 1034 with_asm_arch = 'sparc' 1035 pre_args += ['-DUSE_SPARC_ASM'] 1036 endif 1037 elif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little' 1038 if system_has_kms_drm 1039 with_asm_arch = 'ppc64le' 1040 pre_args += ['-DUSE_PPC64LE_ASM'] 1041 endif 1042 endif 1043endif 1044 1045# Check for standard headers and functions 1046if cc.has_header_symbol('sys/sysmacros.h', 'major') 1047 pre_args += '-DMAJOR_IN_SYSMACROS' 1048elif cc.has_header_symbol('sys/mkdev.h', 'major') 1049 pre_args += '-DMAJOR_IN_MKDEV' 1050endif 1051 1052foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h'] 1053 if cc.compiles('#include <@0@>'.format(h), name : '@0@'.format(h)) 1054 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify()) 1055 endif 1056endforeach 1057 1058foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create'] 1059 if cc.has_function(f) 1060 pre_args += '-DHAVE_@0@'.format(f.to_upper()) 1061 endif 1062endforeach 1063 1064if cc.has_header_symbol('errno.h', 'program_invocation_name', 1065 args : '-D_GNU_SOURCE') 1066 pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME' 1067elif with_tools.contains('intel') 1068 error('Intel tools require the program_invocation_name variable') 1069endif 1070 1071# strtod locale support 1072if cc.links(''' 1073 #define _GNU_SOURCE 1074 #include <stdlib.h> 1075 #include <locale.h> 1076 #ifdef HAVE_XLOCALE_H 1077 #include <xlocale.h> 1078 #endif 1079 int main() { 1080 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL); 1081 const char *s = "1.0"; 1082 char *end; 1083 double d = strtod_l(s, end, loc); 1084 float f = strtof_l(s, end, loc); 1085 freelocale(loc); 1086 return 0; 1087 }''', 1088 args : pre_args, 1089 name : 'strtod has locale support') 1090 pre_args += '-DHAVE_STRTOD_L' 1091endif 1092 1093# Check for some linker flags 1094ld_args_bsymbolic = [] 1095if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic') 1096 ld_args_bsymbolic += '-Wl,-Bsymbolic' 1097endif 1098ld_args_gc_sections = [] 1099if cc.links('static char unused() { return 5; } int main() { return 0; }', 1100 args : '-Wl,--gc-sections', name : 'gc-sections') 1101 ld_args_gc_sections += '-Wl,--gc-sections' 1102endif 1103with_ld_version_script = false 1104if cc.links('int main() { return 0; }', 1105 args : '-Wl,--version-script=@0@'.format( 1106 join_paths(meson.source_root(), 'build-support/conftest.map')), 1107 name : 'version-script') 1108 with_ld_version_script = true 1109endif 1110with_ld_dynamic_list = false 1111if cc.links('int main() { return 0; }', 1112 args : '-Wl,--dynamic-list=@0@'.format( 1113 join_paths(meson.source_root(), 'build-support/conftest.dyn')), 1114 name : 'dynamic-list') 1115 with_ld_dynamic_list = true 1116endif 1117ld_args_build_id = [] 1118if build_machine.system() != 'darwin' 1119 ld_args_build_id += '-Wl,--build-id=sha1' 1120endif 1121 1122# check for dl support 1123if cc.has_function('dlopen') 1124 dep_dl = null_dep 1125else 1126 dep_dl = cc.find_library('dl') 1127endif 1128if cc.has_function('dladdr', dependencies : dep_dl) 1129 # This is really only required for megadrivers 1130 pre_args += '-DHAVE_DLADDR' 1131endif 1132 1133if cc.has_function('dl_iterate_phdr') 1134 pre_args += '-DHAVE_DL_ITERATE_PHDR' 1135elif with_intel_vk 1136 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function') 1137elif with_dri_i965 and with_shader_cache 1138 error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.') 1139endif 1140 1141# Determine whether or not the rt library is needed for time functions 1142if cc.has_function('clock_gettime') 1143 dep_clock = null_dep 1144else 1145 dep_clock = cc.find_library('rt') 1146endif 1147 1148# TODO: some of these may be conditional 1149dep_zlib = dependency('zlib', version : '>= 1.2.3') 1150pre_args += '-DHAVE_ZLIB' 1151dep_thread = dependency('threads') 1152if dep_thread.found() and host_machine.system() != 'windows' 1153 pre_args += '-DHAVE_PTHREAD' 1154 if cc.has_function( 1155 'pthread_setaffinity_np', 1156 dependencies : dep_thread, 1157 prefix : '#include <pthread.h>', 1158 args : '-D_GNU_SOURCE') 1159 pre_args += '-DHAVE_PTHREAD_SETAFFINITY' 1160 endif 1161endif 1162dep_expat = dependency('expat') 1163# this only exists on linux so either this is linux and it will be found, or 1164# its not linux and and wont 1165dep_m = cc.find_library('m', required : false) 1166 1167# Check for libdrm. various drivers have different libdrm version requirements, 1168# but we always want to use the same version for all libdrm modules. That means 1169# even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and 1170# bar are both on use 2.4.3 for both of them 1171dep_libdrm_amdgpu = null_dep 1172dep_libdrm_radeon = null_dep 1173dep_libdrm_nouveau = null_dep 1174dep_libdrm_etnaviv = null_dep 1175dep_libdrm_intel = null_dep 1176 1177_drm_amdgpu_ver = '2.4.97' 1178_drm_radeon_ver = '2.4.71' 1179_drm_nouveau_ver = '2.4.66' 1180_drm_etnaviv_ver = '2.4.89' 1181_drm_intel_ver = '2.4.75' 1182_drm_ver = '2.4.81' 1183 1184_libdrm_checks = [ 1185 ['intel', with_dri_i915 or with_gallium_i915], 1186 ['amdgpu', with_amd_vk or with_gallium_radeonsi], 1187 ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or 1188 with_gallium_r300 or with_gallium_r600)], 1189 ['nouveau', (with_gallium_nouveau or with_dri_nouveau)], 1190 ['etnaviv', with_gallium_etnaviv], 1191] 1192 1193# VC4 only needs core libdrm support of this version, not a libdrm_vc4 1194# library. 1195if with_gallium_vc4 1196 _drm_ver = '2.4.89' 1197endif 1198 1199# Loop over the enables versions and get the highest libdrm requirement for all 1200# active drivers. 1201_drm_blame = '' 1202foreach d : _libdrm_checks 1203 ver = get_variable('_drm_@0@_ver'.format(d[0])) 1204 if d[1] and ver.version_compare('>' + _drm_ver) 1205 _drm_ver = ver 1206 _drm_blame = d[0] 1207 endif 1208endforeach 1209if _drm_blame != '' 1210 message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame)) 1211endif 1212 1213# Then get each libdrm module 1214foreach d : _libdrm_checks 1215 if d[1] 1216 set_variable( 1217 'dep_libdrm_' + d[0], 1218 dependency('libdrm_' + d[0], version : '>=' + _drm_ver) 1219 ) 1220 endif 1221endforeach 1222 1223with_gallium_drisw_kms = false 1224dep_libdrm = dependency( 1225 'libdrm', version : '>=' + _drm_ver, 1226 required : with_dri2 or with_dri3 1227) 1228if dep_libdrm.found() 1229 pre_args += '-DHAVE_LIBDRM' 1230 if with_dri_platform == 'drm' and with_dri 1231 with_gallium_drisw_kms = true 1232 endif 1233endif 1234 1235llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit'] 1236llvm_optional_modules = [] 1237if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 1238 llvm_modules += ['amdgpu', 'native', 'bitreader', 'ipo'] 1239 if with_gallium_r600 1240 llvm_modules += 'asmparser' 1241 endif 1242endif 1243if with_gallium_opencl 1244 llvm_modules += [ 1245 'all-targets', 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader', 1246 'lto', 'option', 'objcarcopts', 'profiledata', 1247 ] 1248 llvm_optional_modules += ['coroutines'] 1249endif 1250 1251if with_amd_vk or with_gallium_radeonsi 1252 _llvm_version = '>= 7.0.0' 1253elif with_gallium_swr 1254 _llvm_version = '>= 6.0.0' 1255elif with_gallium_opencl or with_gallium_r600 1256 _llvm_version = '>= 3.9.0' 1257else 1258 _llvm_version = '>= 3.3.0' 1259endif 1260 1261_shared_llvm = get_option('shared-llvm') 1262 1263_llvm = get_option('llvm') 1264dep_llvm = null_dep 1265with_llvm = false 1266if _llvm != 'false' 1267 dep_llvm = dependency( 1268 'llvm', 1269 version : _llvm_version, 1270 modules : llvm_modules, 1271 optional_modules : llvm_optional_modules, 1272 required : ( 1273 with_amd_vk or with_gallium_radeonsi or with_gallium_swr or 1274 with_gallium_opencl or _llvm == 'true' 1275 ), 1276 static : not _shared_llvm, 1277 method : 'config-tool', 1278 ) 1279 with_llvm = dep_llvm.found() 1280endif 1281if with_llvm 1282 _llvm_version = dep_llvm.version().split('.') 1283 pre_args += [ 1284 '-DHAVE_LLVM=0x0@0@0@1@'.format(_llvm_version[0], _llvm_version[1]), 1285 '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version()), 1286 ] 1287 1288 # LLVM can be built without rtti, turning off rtti changes the ABI of C++ 1289 # programs, so we need to build all C++ code in mesa without rtti as well to 1290 # ensure that linking works. 1291 if dep_llvm.get_configtool_variable('has-rtti') == 'NO' 1292 if with_gallium_nouveau 1293 error('The Nouveau driver requires rtti. You either need to turn off nouveau or use an LLVM built with LLVM_ENABLE_RTTI.') 1294 elif with_gallium_opencl 1295 error('The Clover OpenCL state tracker requires rtti, you need to turn off clover or use an LLVM built with LLVM_ENABLE_RTTI.') 1296 endif 1297 cpp_args += '-fno-rtti' 1298 endif 1299elif with_amd_vk or with_gallium_radeonsi or with_gallium_swr 1300 error('The following drivers require LLVM: Radv, RadeonSI, SWR. One of these is enabled, but LLVM is disabled.') 1301elif with_gallium_opencl 1302 error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.') 1303endif 1304 1305if (with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or 1306 (with_gallium_r600 and with_llvm)) 1307 dep_elf = dependency('libelf', required : false) 1308 if not dep_elf.found() 1309 dep_elf = cc.find_library('elf') 1310 endif 1311else 1312 dep_elf = null_dep 1313endif 1314 1315dep_glvnd = null_dep 1316if with_glvnd 1317 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0') 1318 pre_args += '-DUSE_LIBGLVND=1' 1319endif 1320 1321if with_valgrind != 'false' 1322 dep_valgrind = dependency('valgrind', required : with_valgrind == 'true') 1323 if dep_valgrind.found() 1324 pre_args += '-DHAVE_VALGRIND' 1325 endif 1326else 1327 dep_valgrind = null_dep 1328endif 1329 1330# pthread stubs. Lets not and say we didn't 1331 1332prog_bison = find_program('bison', required : with_any_opengl) 1333prog_flex = find_program('flex', required : with_any_opengl) 1334 1335dep_selinux = null_dep 1336if get_option('selinux') 1337 dep_selinux = dependency('libselinux') 1338 pre_args += '-DMESA_SELINUX' 1339endif 1340 1341if with_libunwind != 'false' 1342 dep_unwind = dependency('libunwind', required : with_libunwind == 'true') 1343 if dep_unwind.found() 1344 pre_args += '-DHAVE_LIBUNWIND' 1345 endif 1346else 1347 dep_unwind = null_dep 1348endif 1349 1350if with_osmesa != 'none' 1351 if with_osmesa == 'classic' and not with_dri_swrast 1352 error('OSMesa classic requires dri (classic) swrast.') 1353 endif 1354 if with_osmesa == 'gallium' and not with_gallium_softpipe 1355 error('OSMesa gallium requires gallium softpipe or llvmpipe.') 1356 endif 1357 osmesa_lib_name = 'OSMesa' 1358 osmesa_bits = get_option('osmesa-bits') 1359 if osmesa_bits != '8' 1360 if with_dri or with_glx != 'disabled' 1361 error('OSMesa bits must be 8 if building glx or dir based drivers') 1362 endif 1363 osmesa_lib_name = osmesa_lib_name + osmesa_bits 1364 pre_args += [ 1365 '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31' 1366 ] 1367 endif 1368endif 1369 1370# TODO: symbol mangling 1371 1372if with_platform_wayland 1373 dep_wl_scanner = dependency('wayland-scanner', native: true) 1374 prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner')) 1375 if dep_wl_scanner.version().version_compare('>= 1.15') 1376 wl_scanner_arg = 'private-code' 1377 else 1378 wl_scanner_arg = 'code' 1379 endif 1380 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8') 1381 dep_wayland_client = dependency('wayland-client', version : '>=1.11') 1382 dep_wayland_server = dependency('wayland-server', version : '>=1.11') 1383 if with_egl 1384 dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3') 1385 dep_wayland_egl_headers = declare_dependency( 1386 compile_args : run_command(prog_pkgconfig, ['wayland-egl-backend', '--cflags']).stdout().split()) 1387 endif 1388 wayland_dmabuf_xml = join_paths( 1389 dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable', 1390 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml' 1391 ) 1392 pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED'] 1393endif 1394 1395dep_x11 = null_dep 1396dep_xext = null_dep 1397dep_xdamage = null_dep 1398dep_xfixes = null_dep 1399dep_x11_xcb = null_dep 1400dep_xcb = null_dep 1401dep_xcb_glx = null_dep 1402dep_xcb_dri2 = null_dep 1403dep_xcb_dri3 = null_dep 1404dep_dri2proto = null_dep 1405dep_glproto = null_dep 1406dep_xxf86vm = null_dep 1407dep_xcb_dri3 = null_dep 1408dep_xcb_present = null_dep 1409dep_xcb_sync = null_dep 1410dep_xcb_xfixes = null_dep 1411dep_xshmfence = null_dep 1412dep_xcb_xrandr = null_dep 1413dep_xlib_xrandr = null_dep 1414if with_platform_x11 1415 if with_glx == 'xlib' or with_glx == 'gallium-xlib' 1416 dep_x11 = dependency('x11') 1417 dep_xext = dependency('xext') 1418 dep_xcb = dependency('xcb') 1419 elif with_glx == 'dri' 1420 dep_x11 = dependency('x11') 1421 dep_xext = dependency('xext') 1422 dep_xdamage = dependency('xdamage', version : '>= 1.1') 1423 dep_xfixes = dependency('xfixes') 1424 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1') 1425 endif 1426 if (with_any_vk or with_glx == 'dri' or with_egl or 1427 (with_gallium_vdpau or with_gallium_xvmc or with_gallium_va or 1428 with_gallium_omx != 'disabled')) 1429 dep_xcb = dependency('xcb') 1430 dep_x11_xcb = dependency('x11-xcb') 1431 endif 1432 if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm') 1433 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8') 1434 1435 if with_dri3 1436 pre_args += '-DHAVE_DRI3' 1437 dep_xcb_dri3 = dependency('xcb-dri3') 1438 dep_xcb_present = dependency('xcb-present') 1439 # until xcb-dri3 has been around long enough to make a hard-dependency: 1440 if (dep_xcb_dri3.version().version_compare('>= 1.13') and 1441 dep_xcb_present.version().version_compare('>= 1.13')) 1442 pre_args += '-DHAVE_DRI3_MODIFIERS' 1443 endif 1444 dep_xcb_sync = dependency('xcb-sync') 1445 dep_xshmfence = dependency('xshmfence', version : '>= 1.1') 1446 endif 1447 endif 1448 if with_glx == 'dri' or with_glx == 'gallium-xlib' 1449 dep_glproto = dependency('glproto', version : '>= 1.4.14') 1450 endif 1451 if with_glx == 'dri' 1452 if with_dri_platform == 'drm' 1453 dep_dri2proto = dependency('dri2proto', version : '>= 2.8') 1454 dep_xxf86vm = dependency('xxf86vm') 1455 endif 1456 endif 1457 if (with_egl or ( 1458 with_gallium_vdpau or with_gallium_xvmc or with_gallium_xa or 1459 with_gallium_omx != 'disabled')) 1460 dep_xcb_xfixes = dependency('xcb-xfixes') 1461 endif 1462 if with_xlib_lease 1463 dep_xcb_xrandr = dependency('xcb-randr') 1464 dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3') 1465 endif 1466endif 1467 1468if get_option('gallium-extra-hud') 1469 pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1' 1470endif 1471 1472_sensors = get_option('lmsensors') 1473if _sensors != 'false' 1474 dep_lmsensors = cc.find_library('sensors', required : _sensors == 'true') 1475 if dep_lmsensors.found() 1476 pre_args += '-DHAVE_LIBSENSORS=1' 1477 endif 1478else 1479 dep_lmsensors = null_dep 1480endif 1481 1482foreach a : pre_args 1483 add_project_arguments(a, language : ['c', 'cpp']) 1484endforeach 1485foreach a : c_args 1486 add_project_arguments(a, language : ['c']) 1487endforeach 1488foreach a : cpp_args 1489 add_project_arguments(a, language : ['cpp']) 1490endforeach 1491 1492gl_priv_reqs = [] 1493 1494if with_glx == 'xlib' or with_glx == 'gallium-xlib' 1495 gl_priv_reqs += ['x11', 'xext', 'xcb'] 1496elif with_glx == 'dri' 1497 gl_priv_reqs += [ 1498 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb', 1499 'xcb-glx >= 1.8.1'] 1500 if with_dri_platform == 'drm' 1501 gl_priv_reqs += 'xcb-dri2 >= 1.8' 1502 gl_priv_reqs += 'xxf86vm' 1503 endif 1504endif 1505if dep_libdrm.found() 1506 gl_priv_reqs += 'libdrm >= 2.4.75' 1507endif 1508 1509gl_priv_libs = [] 1510if dep_thread.found() 1511 gl_priv_libs += ['-lpthread', '-pthread'] 1512endif 1513if dep_m.found() 1514 gl_priv_libs += '-lm' 1515endif 1516if dep_dl.found() 1517 gl_priv_libs += '-ldl' 1518endif 1519 1520pkg = import('pkgconfig') 1521 1522prog_nm = find_program('nm', required : false) 1523env_test = environment() 1524if prog_nm.found() 1525 env_test.set('NM', prog_nm.path()) 1526endif 1527 1528# This quirk needs to be applied to sources with functions defined in assembly 1529# as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391 1530gcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : [] 1531 1532subdir('include') 1533subdir('bin') 1534subdir('src') 1535 1536# Meson 0.49 and earlier seems to have a bug that fails to evaluate the string- 1537# formatting below unless the first argument is passed as a variable. This has 1538# been fixed in Meson 0.50 and beyond, but we need to keep it like this for now 1539# for backwards compatibility. 1540_with_opengl_string = with_opengl ? 'yes' : 'no' 1541 1542lines = ['', 1543 'prefix: ' + get_option('prefix'), 1544 'libdir: ' + get_option('libdir'), 1545 'includedir: ' + get_option('includedir'), 1546 '', 1547 'OpenGL: @0@ (ES1: @1@ ES2: @2@)'.format(_with_opengl_string, 1548 with_gles1 ? 'yes' : 'no', 1549 with_gles2 ? 'yes' : 'no'), 1550] 1551 1552lines += '' 1553if with_osmesa != 'none' 1554 suffix = '' 1555 if with_osmesa == 'gallium' 1556 suffix = '(Gallium)' 1557 endif 1558 lines += 'OSMesa: lib' + osmesa_lib_name + suffix 1559else 1560 lines += 'OSMesa: no' 1561endif 1562 1563lines += '' 1564if with_dri 1565 lines += 'DRI platform: ' + with_dri_platform 1566 if dri_drivers.length() != 0 and dri_drivers != [''] 1567 lines += 'DRI drivers: ' + ' '.join(dri_drivers) 1568 else 1569 lines += 'DRI drivers: no' 1570 endif 1571 lines += 'DRI driver dir: ' + dri_drivers_path 1572endif 1573 1574lines += '' 1575if with_glx != 'disabled' 1576 if with_glx == 'dri' 1577 lines += 'GLX: DRI-based' 1578 elif with_glx == 'xlib' 1579 lines += 'GLX: Xlib-based' 1580 elif with_glx == 'gallium-xlib' 1581 lines += 'GLX: Xlib-based (Gallium)' 1582 else 1583 lines += 'GLX: ' + with_glx 1584 endif 1585endif 1586 1587lines += '' 1588lines += 'EGL: ' + (with_egl ? 'yes' : 'no') 1589if with_egl 1590 egl_drivers = [] 1591 if with_dri 1592 egl_drivers += 'builtin:egl_dri2' 1593 endif 1594 if with_dri3 1595 egl_drivers += 'builtin:egl_dri3' 1596 endif 1597 lines += 'EGL drivers: ' + ' '.join(egl_drivers) 1598endif 1599lines += 'GBM: ' + (with_gbm ? 'yes' : 'no') 1600if with_platforms 1601 lines += 'EGL/Vulkan/VL platforms: ' + ' '.join(_platforms) 1602endif 1603 1604lines += '' 1605if with_any_vk 1606 lines += 'Vulkan drivers: ' + ' '.join(_vulkan_drivers) 1607 lines += 'Vulkan ICD dir: ' + with_vulkan_icd_dir 1608else 1609 lines += 'Vulkan drivers: no' 1610endif 1611 1612lines += '' 1613if with_llvm 1614 lines += 'llvm: yes' 1615 lines += 'llvm-version: ' + dep_llvm.version() 1616else 1617 lines += 'llvm: no' 1618endif 1619 1620lines += '' 1621if with_gallium 1622 lines += 'Gallium drivers: ' + ' '.join(gallium_drivers) 1623 gallium_st = ['mesa'] 1624 if with_gallium_xa 1625 gallium_st += 'xa' 1626 endif 1627 if with_gallium_xvmc 1628 gallium_st += 'xvmc' 1629 endif 1630 if with_gallium_xvmc 1631 gallium_st += 'xvmc' 1632 endif 1633 if with_gallium_vdpau 1634 gallium_st += 'vdpau' 1635 endif 1636 if with_gallium_omx != 'disabled' 1637 gallium_st += 'omx' + with_gallium_omx 1638 endif 1639 if with_gallium_va 1640 gallium_st += 'va' 1641 endif 1642 if with_gallium_st_nine 1643 gallium_st += 'nine' 1644 endif 1645 if with_gallium_opencl 1646 gallium_st += 'clover' 1647 endif 1648 lines += 'Gallium st: ' + ' '.join(gallium_st) 1649else 1650 lines += 'Gallium: no' 1651endif 1652 1653lines += 'HUD lmsensors: ' + (dep_lmsensors.found() ? 'yes' : 'no') 1654 1655lines += '' 1656lines += 'Shared-glapi: ' + (with_shared_glapi ? 'yes' : 'no') 1657 1658 1659indent = ' ' 1660summary = indent + ('\n' + indent).join(lines) 1661message('Configuration summary:\n@0@\n'.format(summary)) 1662