17ec681f3Smrg# Copyright © 2017-2020 Intel Corporation 201e04c3fSmrg 301e04c3fSmrg# Permission is hereby granted, free of charge, to any person obtaining a copy 401e04c3fSmrg# of this software and associated documentation files (the "Software"), to deal 501e04c3fSmrg# in the Software without restriction, including without limitation the rights 601e04c3fSmrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 701e04c3fSmrg# copies of the Software, and to permit persons to whom the Software is 801e04c3fSmrg# furnished to do so, subject to the following conditions: 901e04c3fSmrg 1001e04c3fSmrg# The above copyright notice and this permission notice shall be included in 1101e04c3fSmrg# all copies or substantial portions of the Software. 1201e04c3fSmrg 1301e04c3fSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1401e04c3fSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1501e04c3fSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1601e04c3fSmrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1701e04c3fSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 1801e04c3fSmrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1901e04c3fSmrg# SOFTWARE. 2001e04c3fSmrg 2101e04c3fSmrgproject( 2201e04c3fSmrg 'mesa', 2301e04c3fSmrg ['c', 'cpp'], 2401e04c3fSmrg version : run_command( 257ec681f3Smrg [find_program('python3', 'python'), 'bin/meson_get_version.py'], 267ec681f3Smrg check : true 2701e04c3fSmrg ).stdout(), 2801e04c3fSmrg license : 'MIT', 297ec681f3Smrg meson_version : '>= 0.52', 307ec681f3Smrg default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++14'] 3101e04c3fSmrg) 3201e04c3fSmrg 3301e04c3fSmrgcc = meson.get_compiler('c') 3401e04c3fSmrgcpp = meson.get_compiler('cpp') 3501e04c3fSmrg 3601e04c3fSmrgnull_dep = dependency('', required : false) 3701e04c3fSmrg 387ec681f3Smrgif get_option('layout') != 'mirror' 397ec681f3Smrg error('`mirror` is the only build directory layout supported') 407ec681f3Smrgendif 417ec681f3Smrg 4201e04c3fSmrg# Arguments for the preprocessor, put these in a separate array from the C and 4301e04c3fSmrg# C++ (cpp in meson terminology) arguments since they need to be added to the 4401e04c3fSmrg# default arguments for both C and C++. 4501e04c3fSmrgpre_args = [ 4601e04c3fSmrg '-D__STDC_CONSTANT_MACROS', 4701e04c3fSmrg '-D__STDC_FORMAT_MACROS', 4801e04c3fSmrg '-D__STDC_LIMIT_MACROS', 4953c12917Smaya '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()), 507ec681f3Smrg '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/-/issues"', 5101e04c3fSmrg] 527ec681f3Smrgc_args = [] 537ec681f3Smrgcpp_args = [] 5401e04c3fSmrg 557ec681f3Smrgwith_moltenvk_dir = get_option('moltenvk-dir') 5601e04c3fSmrgwith_vulkan_icd_dir = get_option('vulkan-icd-dir') 5701e04c3fSmrgwith_tests = get_option('build-tests') 587ec681f3Smrgwith_aco_tests = get_option('build-aco-tests') 5901e04c3fSmrgwith_glx_read_only_text = get_option('glx-read-only-text') 6001e04c3fSmrgwith_glx_direct = get_option('glx-direct') 6101e04c3fSmrgwith_osmesa = get_option('osmesa') 6201e04c3fSmrgwith_swr_arches = get_option('swr-arches') 637ec681f3Smrgwith_vulkan_overlay_layer = get_option('vulkan-layers').contains('overlay') 647ec681f3Smrgwith_vulkan_device_select_layer = get_option('vulkan-layers').contains('device-select') 6501e04c3fSmrgwith_tools = get_option('tools') 6601e04c3fSmrgif with_tools.contains('all') 677ec681f3Smrg with_tools = [ 687ec681f3Smrg 'drm-shim', 697ec681f3Smrg 'etnaviv', 707ec681f3Smrg 'freedreno', 717ec681f3Smrg 'glsl', 727ec681f3Smrg 'intel', 737ec681f3Smrg 'intel-ui', 747ec681f3Smrg 'lima', 757ec681f3Smrg 'nir', 767ec681f3Smrg 'nouveau', 777ec681f3Smrg 'xvmc', 787ec681f3Smrg 'asahi', 797ec681f3Smrg ] 8001e04c3fSmrgendif 8101e04c3fSmrg 827ec681f3Smrgwith_any_vulkan_layers = get_option('vulkan-layers').length() != 0 837ec681f3Smrgwith_intel_tools = with_tools.contains('intel') or with_tools.contains('intel-ui') 847ec681f3Smrgwith_imgui = with_intel_tools or with_vulkan_overlay_layer 857ec681f3Smrg 8601e04c3fSmrgdri_drivers_path = get_option('dri-drivers-path') 8701e04c3fSmrgif dri_drivers_path == '' 88993e1d59Smrg dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri') 8901e04c3fSmrgendif 9001e04c3fSmrgdri_search_path = get_option('dri-search-path') 9101e04c3fSmrgif dri_search_path == '' 92993e1d59Smrg dri_search_path = dri_drivers_path 9301e04c3fSmrgendif 9401e04c3fSmrg 957ec681f3Smrggbm_backends_path = get_option('gbm-backends-path') 967ec681f3Smrgif gbm_backends_path == '' 977ec681f3Smrg gbm_backends_path = join_paths(get_option('prefix'), get_option('libdir'), 'gbm') 987ec681f3Smrgendif 997ec681f3Smrg 10001e04c3fSmrgwith_gles1 = get_option('gles1') 1017ec681f3Smrgif with_gles1 == 'true' 1027ec681f3Smrg with_gles1 = 'enabled' 1037ec681f3Smrg warning('gles1 option "true" deprecated, please use "enabled" instead.') 1047ec681f3Smrgelif with_gles1 == 'false' 1057ec681f3Smrg with_gles1 = 'disabled' 1067ec681f3Smrg warning('gles1 option "false" deprecated, please use "disabled" instead.') 1077ec681f3Smrgendif 10801e04c3fSmrgwith_gles2 = get_option('gles2') 1097ec681f3Smrgif with_gles2 == 'true' 1107ec681f3Smrg with_gles2 = 'enabled' 1117ec681f3Smrg warning('gles2 option "true" deprecated, please use "enabled" instead.') 1127ec681f3Smrgelif with_gles2 == 'false' 1137ec681f3Smrg with_gles2 = 'disabled' 1147ec681f3Smrg warning('gles2 option "false" deprecated, please use "disabled" instead.') 1157ec681f3Smrgendif 11653c12917Smayaif host_machine.system() == 'windows' 11753c12917Smaya if with_gles1 == 'auto' 1187ec681f3Smrg with_gles1 = 'disabled' 11953c12917Smaya endif 12053c12917Smaya if with_gles2 == 'auto' 1217ec681f3Smrg with_gles2 = 'disabled' 12253c12917Smaya endif 12353c12917Smayaendif 12401e04c3fSmrgwith_opengl = get_option('opengl') 1257ec681f3Smrg 1267ec681f3Smrg# Default shared glapi off for windows, on elsewhere. 1277ec681f3Smrg_sg = get_option('shared-glapi') 1287ec681f3Smrgif _sg == 'true' 1297ec681f3Smrg _sg = 'enabled' 1307ec681f3Smrg warning('shared-glapi option "true" deprecated, please use "enabled" instead.') 1317ec681f3Smrgelif _sg == 'false' 1327ec681f3Smrg _sg = 'disabled' 1337ec681f3Smrg warning('shared-glapi option "false" deprecated, please use "disabled" instead.') 1347ec681f3Smrgendif 1357ec681f3Smrgif _sg == 'auto' 1367ec681f3Smrg with_shared_glapi = host_machine.system() != 'windows' 1377ec681f3Smrgelse 1387ec681f3Smrg with_shared_glapi = _sg == 'enabled' 1397ec681f3Smrgendif 14001e04c3fSmrg 14101e04c3fSmrg# shared-glapi is required if at least two OpenGL APIs are being built 14201e04c3fSmrgif not with_shared_glapi 1437ec681f3Smrg if ((with_gles1 == 'enabled' and with_gles2 == 'enabled') or 1447ec681f3Smrg (with_gles1 == 'enabled' and with_opengl) or 1457ec681f3Smrg (with_gles2 == 'enabled' and with_opengl)) 14601e04c3fSmrg error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x') 14701e04c3fSmrg endif 1487ec681f3Smrg with_gles1 = 'disabled' 1497ec681f3Smrg with_gles2 = 'disabled' 15001e04c3fSmrgendif 15101e04c3fSmrg 15201e04c3fSmrg# We require OpenGL for OpenGL ES 15353c12917Smayaif not with_opengl 1547ec681f3Smrg if (with_gles1 == 'enabled' or with_gles2 == 'enabled') and not with_opengl 15553c12917Smaya error('building OpenGL ES without OpenGL is not supported.') 15653c12917Smaya endif 1577ec681f3Smrg with_gles1 = 'disabled' 1587ec681f3Smrg with_gles2 = 'disabled' 15901e04c3fSmrgendif 16001e04c3fSmrg 1617ec681f3Smrgwith_gles1 = with_gles1 != 'disabled' 1627ec681f3Smrgwith_gles2 = with_gles2 != 'disabled' 16353c12917Smayawith_any_opengl = with_opengl or with_gles1 or with_gles2 16453c12917Smaya# Only build shared_glapi if at least one OpenGL API is enabled 1657ec681f3Smrgwith_shared_glapi = with_shared_glapi and with_any_opengl 16653c12917Smaya 1677ec681f3Smrgsystem_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos'].contains(host_machine.system()) 16801e04c3fSmrg 16953c12917Smayadri_drivers = get_option('dri-drivers') 17053c12917Smayaif dri_drivers.contains('auto') 17101e04c3fSmrg if system_has_kms_drm 17201e04c3fSmrg # TODO: PPC, Sparc 17301e04c3fSmrg if ['x86', 'x86_64'].contains(host_machine.cpu_family()) 17453c12917Smaya dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau'] 17501e04c3fSmrg elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 17653c12917Smaya dri_drivers = [] 1777ec681f3Smrg elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family()) 1787ec681f3Smrg dri_drivers = ['r100', 'r200', 'nouveau'] 17901e04c3fSmrg else 18001e04c3fSmrg error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format( 18101e04c3fSmrg host_machine.cpu_family())) 18201e04c3fSmrg endif 18301e04c3fSmrg elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) 18401e04c3fSmrg # only swrast would make sense here, but gallium swrast is a much better default 18553c12917Smaya dri_drivers = [] 18601e04c3fSmrg else 18701e04c3fSmrg error('Unknown OS @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format( 18801e04c3fSmrg host_machine.system())) 18901e04c3fSmrg endif 19001e04c3fSmrgendif 19101e04c3fSmrg 19253c12917Smayawith_dri_i915 = dri_drivers.contains('i915') 19353c12917Smayawith_dri_i965 = dri_drivers.contains('i965') 19453c12917Smayawith_dri_r100 = dri_drivers.contains('r100') 19553c12917Smayawith_dri_r200 = dri_drivers.contains('r200') 19653c12917Smayawith_dri_nouveau = dri_drivers.contains('nouveau') 19701e04c3fSmrg 1987ec681f3Smrgwith_dri = dri_drivers.length() != 0 19901e04c3fSmrg 20053c12917Smayagallium_drivers = get_option('gallium-drivers') 20153c12917Smayaif gallium_drivers.contains('auto') 20201e04c3fSmrg if system_has_kms_drm 20301e04c3fSmrg # TODO: PPC, Sparc 20401e04c3fSmrg if ['x86', 'x86_64'].contains(host_machine.cpu_family()) 20553c12917Smaya gallium_drivers = [ 2067ec681f3Smrg 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast', 2077ec681f3Smrg 'iris', 'crocus' 20801e04c3fSmrg ] 20901e04c3fSmrg elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 21053c12917Smaya gallium_drivers = [ 2117ec681f3Smrg 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau', 2127ec681f3Smrg 'tegra', 'virgl', 'lima', 'panfrost', 'swrast' 2137ec681f3Smrg ] 2147ec681f3Smrg elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family()) 2157ec681f3Smrg gallium_drivers = [ 2167ec681f3Smrg 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'swrast' 21701e04c3fSmrg ] 21801e04c3fSmrg else 21901e04c3fSmrg error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format( 22001e04c3fSmrg host_machine.cpu_family())) 22101e04c3fSmrg endif 22201e04c3fSmrg elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) 22353c12917Smaya gallium_drivers = ['swrast'] 22401e04c3fSmrg else 22501e04c3fSmrg error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format( 22601e04c3fSmrg host_machine.system())) 22701e04c3fSmrg endif 22801e04c3fSmrgendif 22953c12917Smayawith_gallium_radeonsi = gallium_drivers.contains('radeonsi') 23053c12917Smayawith_gallium_r300 = gallium_drivers.contains('r300') 23153c12917Smayawith_gallium_r600 = gallium_drivers.contains('r600') 23253c12917Smayawith_gallium_nouveau = gallium_drivers.contains('nouveau') 23353c12917Smayawith_gallium_freedreno = gallium_drivers.contains('freedreno') 23453c12917Smayawith_gallium_softpipe = gallium_drivers.contains('swrast') 23553c12917Smayawith_gallium_vc4 = gallium_drivers.contains('vc4') 23653c12917Smayawith_gallium_v3d = gallium_drivers.contains('v3d') 23753c12917Smayawith_gallium_panfrost = gallium_drivers.contains('panfrost') 23853c12917Smayawith_gallium_etnaviv = gallium_drivers.contains('etnaviv') 23953c12917Smayawith_gallium_tegra = gallium_drivers.contains('tegra') 2407ec681f3Smrgwith_gallium_crocus = gallium_drivers.contains('crocus') 24153c12917Smayawith_gallium_iris = gallium_drivers.contains('iris') 24253c12917Smayawith_gallium_i915 = gallium_drivers.contains('i915') 24353c12917Smayawith_gallium_svga = gallium_drivers.contains('svga') 24453c12917Smayawith_gallium_virgl = gallium_drivers.contains('virgl') 24553c12917Smayawith_gallium_swr = gallium_drivers.contains('swr') 24653c12917Smayawith_gallium_lima = gallium_drivers.contains('lima') 2477ec681f3Smrgwith_gallium_zink = gallium_drivers.contains('zink') 2487ec681f3Smrgwith_gallium_d3d12 = gallium_drivers.contains('d3d12') 2497ec681f3Smrgwith_gallium_asahi = gallium_drivers.contains('asahi') 25001e04c3fSmrg 2517ec681f3Smrgwith_gallium = gallium_drivers.length() != 0 2527ec681f3Smrgwith_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 25301e04c3fSmrg 25401e04c3fSmrgif with_gallium and system_has_kms_drm 25501e04c3fSmrg _glx = get_option('glx') 25601e04c3fSmrg _egl = get_option('egl') 2577ec681f3Smrg if _glx == 'dri' or _egl == 'enabled' or (_glx == 'disabled' and _egl != 'disabled') 25801e04c3fSmrg with_dri = true 25901e04c3fSmrg endif 26001e04c3fSmrgendif 26101e04c3fSmrg 26201e04c3fSmrg_vulkan_drivers = get_option('vulkan-drivers') 26301e04c3fSmrgif _vulkan_drivers.contains('auto') 26401e04c3fSmrg if system_has_kms_drm 26501e04c3fSmrg if host_machine.cpu_family().startswith('x86') 2667ec681f3Smrg _vulkan_drivers = ['amd', 'intel', 'swrast'] 26701e04c3fSmrg elif ['arm', 'aarch64'].contains(host_machine.cpu_family()) 2687ec681f3Smrg _vulkan_drivers = ['swrast'] 2697ec681f3Smrg elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family()) 2707ec681f3Smrg _vulkan_drivers = ['amd', 'swrast'] 27101e04c3fSmrg else 27201e04c3fSmrg error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format( 27301e04c3fSmrg host_machine.cpu_family())) 27401e04c3fSmrg endif 27501e04c3fSmrg elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) 27601e04c3fSmrg # No vulkan driver supports windows or macOS currently 27701e04c3fSmrg _vulkan_drivers = [] 27801e04c3fSmrg else 27901e04c3fSmrg error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format( 28001e04c3fSmrg host_machine.system())) 28101e04c3fSmrg endif 28201e04c3fSmrgendif 28301e04c3fSmrg 28401e04c3fSmrgwith_intel_vk = _vulkan_drivers.contains('intel') 28501e04c3fSmrgwith_amd_vk = _vulkan_drivers.contains('amd') 28653c12917Smayawith_freedreno_vk = _vulkan_drivers.contains('freedreno') 2877ec681f3Smrgwith_panfrost_vk = _vulkan_drivers.contains('panfrost') 2887ec681f3Smrgwith_swrast_vk = _vulkan_drivers.contains('swrast') 2897ec681f3Smrgwith_virtio_vk = _vulkan_drivers.contains('virtio-experimental') 2907ec681f3Smrgwith_freedreno_kgsl = get_option('freedreno-kgsl') 2917ec681f3Smrgwith_broadcom_vk = _vulkan_drivers.contains('broadcom') 2927ec681f3Smrgwith_any_vk = _vulkan_drivers.length() != 0 29301e04c3fSmrg 2947ec681f3Smrgwith_any_broadcom = with_gallium_vc4 or with_gallium_v3d or with_broadcom_vk 2957ec681f3Smrgwith_any_intel = with_dri_i965 or with_intel_vk or with_gallium_iris or with_gallium_crocus 29653c12917Smaya 2977ec681f3Smrgif with_swrast_vk and not with_gallium_softpipe 2987ec681f3Smrg error('swrast vulkan requires gallium swrast') 29901e04c3fSmrgendif 30001e04c3fSmrgif with_dri_i915 and with_gallium_i915 30101e04c3fSmrg error('Only one i915 provider can be built') 30201e04c3fSmrgendif 30301e04c3fSmrgif with_gallium_tegra and not with_gallium_nouveau 30401e04c3fSmrg error('tegra driver requires nouveau driver') 30501e04c3fSmrgendif 3067ec681f3Smrgif with_aco_tests and not with_amd_vk 3077ec681f3Smrg error('ACO tests require Radv') 3087ec681f3Smrgendif 3097ec681f3Smrg 3107ec681f3Smrgwith_microsoft_clc = get_option('microsoft-clc').enabled() 3117ec681f3Smrgwith_clc = with_microsoft_clc 3127ec681f3Smrgwith_libclc = with_clc 3137ec681f3Smrgwith_spirv_to_dxil = get_option('spirv-to-dxil') 31401e04c3fSmrg 31501e04c3fSmrgif host_machine.system() == 'darwin' 31601e04c3fSmrg with_dri_platform = 'apple' 31753c12917Smaya pre_args += '-DBUILDING_MESA' 31801e04c3fSmrgelif ['windows', 'cygwin'].contains(host_machine.system()) 31901e04c3fSmrg with_dri_platform = 'windows' 32001e04c3fSmrgelif system_has_kms_drm 32101e04c3fSmrg with_dri_platform = 'drm' 32201e04c3fSmrgelse 32301e04c3fSmrg # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should 32401e04c3fSmrg # assert here that one of those cases has been met. 32501e04c3fSmrg # FIXME: illumos ends up here as well 32601e04c3fSmrg with_dri_platform = 'none' 32701e04c3fSmrgendif 32801e04c3fSmrg 32901e04c3fSmrg_platforms = get_option('platforms') 33001e04c3fSmrgif _platforms.contains('auto') 33101e04c3fSmrg if system_has_kms_drm 3327ec681f3Smrg _platforms = ['x11', 'wayland'] 3337ec681f3Smrg elif ['darwin', 'cygwin'].contains(host_machine.system()) 3347ec681f3Smrg _platforms = ['x11'] 33501e04c3fSmrg elif ['haiku'].contains(host_machine.system()) 33601e04c3fSmrg _platforms = ['haiku'] 3377ec681f3Smrg elif host_machine.system() == 'windows' 3387ec681f3Smrg _platforms = ['windows'] 33901e04c3fSmrg else 34001e04c3fSmrg error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format( 34101e04c3fSmrg host_machine.system())) 34201e04c3fSmrg endif 34301e04c3fSmrgendif 34401e04c3fSmrg 34501e04c3fSmrgwith_platform_android = _platforms.contains('android') 34601e04c3fSmrgwith_platform_x11 = _platforms.contains('x11') 34701e04c3fSmrgwith_platform_wayland = _platforms.contains('wayland') 34801e04c3fSmrgwith_platform_haiku = _platforms.contains('haiku') 3497ec681f3Smrgwith_platform_windows = _platforms.contains('windows') 35001e04c3fSmrg 35101e04c3fSmrgwith_glx = get_option('glx') 35201e04c3fSmrgif with_glx == 'auto' 3537ec681f3Smrg if with_platform_android 3547ec681f3Smrg with_glx = 'disabled' 3557ec681f3Smrg elif with_dri 35601e04c3fSmrg with_glx = 'dri' 35701e04c3fSmrg elif with_platform_haiku 35801e04c3fSmrg with_glx = 'disabled' 3597ec681f3Smrg elif host_machine.system() == 'windows' 3607ec681f3Smrg with_glx = 'disabled' 36101e04c3fSmrg elif with_gallium 36201e04c3fSmrg # Even when building just gallium drivers the user probably wants dri 36301e04c3fSmrg with_glx = 'dri' 36401e04c3fSmrg elif with_platform_x11 and with_any_opengl and not with_any_vk 36501e04c3fSmrg # The automatic behavior should not be to turn on xlib based glx when 36601e04c3fSmrg # building only vulkan drivers 36701e04c3fSmrg with_glx = 'xlib' 36801e04c3fSmrg else 36901e04c3fSmrg with_glx = 'disabled' 37001e04c3fSmrg endif 37101e04c3fSmrgendif 37201e04c3fSmrgif with_glx == 'dri' 37301e04c3fSmrg if with_gallium 37401e04c3fSmrg with_dri = true 37501e04c3fSmrg endif 37601e04c3fSmrgendif 37701e04c3fSmrg 37853c12917Smayaif not (with_dri or with_gallium or with_glx != 'disabled') 37901e04c3fSmrg with_gles1 = false 38001e04c3fSmrg with_gles2 = false 38101e04c3fSmrg with_opengl = false 38201e04c3fSmrg with_any_opengl = false 38301e04c3fSmrg with_shared_glapi = false 38401e04c3fSmrgendif 38501e04c3fSmrg 38601e04c3fSmrg_gbm = get_option('gbm') 3877ec681f3Smrgif _gbm == 'true' 3887ec681f3Smrg _gbm = 'enabled' 3897ec681f3Smrg warning('gbm option "true" deprecated, please use "enabled" instead.') 3907ec681f3Smrgelif _gbm == 'false' 3917ec681f3Smrg _gbm = 'disabled' 3927ec681f3Smrg warning('gbm option "false" deprecated, please use "disabled" instead.') 3937ec681f3Smrgendif 39401e04c3fSmrgif _gbm == 'auto' 39501e04c3fSmrg with_gbm = system_has_kms_drm and with_dri 39601e04c3fSmrgelse 3977ec681f3Smrg with_gbm = _gbm == 'enabled' 39801e04c3fSmrgendif 39901e04c3fSmrgif with_gbm and not system_has_kms_drm 40001e04c3fSmrg error('GBM only supports DRM/KMS platforms') 40101e04c3fSmrgendif 40201e04c3fSmrg 4037ec681f3Smrg_xlib_lease = get_option('xlib-lease') 4047ec681f3Smrgif _xlib_lease == 'true' 4057ec681f3Smrg _xlib_lease = 'enabled' 4067ec681f3Smrg warning('xlib_lease option "true" deprecated, please use "enabled" instead.') 4077ec681f3Smrgelif _xlib_lease == 'false' 4087ec681f3Smrg _xlib_lease = 'disabled' 4097ec681f3Smrg warning('xlib_lease option "false" deprecated, please use "disabled" instead.') 4107ec681f3Smrgendif 4117ec681f3Smrgif _xlib_lease == 'auto' 4127ec681f3Smrg with_xlib_lease = with_platform_x11 and system_has_kms_drm 4137ec681f3Smrgelse 4147ec681f3Smrg with_xlib_lease = _xlib_lease == 'enabled' 4157ec681f3Smrgendif 4167ec681f3Smrg 4177ec681f3Smrgif with_platform_wayland 4187ec681f3Smrg c_args += '-DVK_USE_PLATFORM_WAYLAND_KHR' 4197ec681f3Smrg #add this once aco and other places can build with it 4207ec681f3Smrg #cpp_args += '-DVK_USE_PLATFORM_WAYLAND_KHR' 4217ec681f3Smrgendif 4227ec681f3Smrgif with_platform_x11 4237ec681f3Smrg c_args += ['-DVK_USE_PLATFORM_XCB_KHR', '-DVK_USE_PLATFORM_XLIB_KHR'] 4247ec681f3Smrg #add this once aco and other places can build with it 4257ec681f3Smrg #cpp_args += ['-DVK_USE_PLATFORM_XCB_KHR', '-DVK_USE_PLATFORM_XLIB_KHR'] 4267ec681f3Smrgendif 4277ec681f3Smrgif with_platform_windows 4287ec681f3Smrg c_args += '-DVK_USE_PLATFORM_WIN32_KHR' 4297ec681f3Smrg #add this once aco and other places can build with it 4307ec681f3Smrg #cpp_args += '-DVK_USE_PLATFORM_WIN32_KHR' 4317ec681f3Smrgendif 4327ec681f3Smrgif with_platform_android 4337ec681f3Smrg c_args += '-DVK_USE_PLATFORM_ANDROID_KHR' 4347ec681f3Smrg cpp_args += '-DVK_USE_PLATFORM_ANDROID_KHR' 4357ec681f3Smrgendif 4367ec681f3Smrgif with_xlib_lease 4377ec681f3Smrg c_args += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT' 4387ec681f3Smrg #add this once aco and other places can build with it 4397ec681f3Smrg #cpp_args += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT' 4407ec681f3Smrgendif 4417ec681f3Smrgif system_has_kms_drm and not with_platform_android 4427ec681f3Smrg c_args += '-DVK_USE_PLATFORM_DISPLAY_KHR' 4437ec681f3Smrg cpp_args += '-DVK_USE_PLATFORM_DISPLAY_KHR' 4447ec681f3Smrgendif 4457ec681f3Smrg 44601e04c3fSmrg_egl = get_option('egl') 4477ec681f3Smrgif _egl == 'true' 4487ec681f3Smrg _egl = 'enabled' 4497ec681f3Smrg warning('egl option "true" deprecated, please use "enabled" instead.') 4507ec681f3Smrgelif _egl == 'false' 4517ec681f3Smrg _egl = 'disabled' 4527ec681f3Smrg warning('egl option "false" deprecated, please use "disabled" instead.') 4537ec681f3Smrgendif 45401e04c3fSmrgif _egl == 'auto' 45501e04c3fSmrg with_egl = ( 4567ec681f3Smrg host_machine.system() != 'darwin' and 4577ec681f3Smrg (with_platform_windows or with_dri) and 4587ec681f3Smrg with_shared_glapi 45901e04c3fSmrg ) 4607ec681f3Smrgelif _egl == 'enabled' 4617ec681f3Smrg if not with_dri and not with_platform_haiku and not with_platform_windows 4627ec681f3Smrg error('EGL requires dri, haiku, or windows') 46301e04c3fSmrg elif not with_shared_glapi 46401e04c3fSmrg error('EGL requires shared-glapi') 46501e04c3fSmrg elif not ['disabled', 'dri'].contains(with_glx) 46601e04c3fSmrg error('EGL requires dri, but a GLX is being built without dri') 4677ec681f3Smrg elif host_machine.system() == 'darwin' 4687ec681f3Smrg error('EGL is not available on MacOS') 46901e04c3fSmrg endif 47001e04c3fSmrg with_egl = true 47101e04c3fSmrgelse 47201e04c3fSmrg with_egl = false 47301e04c3fSmrgendif 47401e04c3fSmrg 4757ec681f3Smrgif with_egl 4767ec681f3Smrg _platforms += 'surfaceless' 4777ec681f3Smrg if with_gbm and not with_platform_android 4787ec681f3Smrg _platforms += 'drm' 47901e04c3fSmrg endif 4807ec681f3Smrgendif 4817ec681f3Smrg 4827ec681f3Smrgegl_native_platform = get_option('egl-native-platform') 4837ec681f3Smrgif egl_native_platform.contains('auto') 4847ec681f3Smrg if _platforms.length() != 0 4857ec681f3Smrg egl_native_platform = _platforms[0] 4867ec681f3Smrg else 4877ec681f3Smrg egl_native_platform = 'surfaceless' 4887ec681f3Smrg endif 4897ec681f3Smrgendif 4907ec681f3Smrg 4917ec681f3Smrgif with_egl and not _platforms.contains(egl_native_platform) 4927ec681f3Smrg error('-Degl-native-platform does not specify an enabled platform') 4937ec681f3Smrgendif 4947ec681f3Smrg 4957ec681f3Smrg# Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS. 4967ec681f3Smrguse_elf_tls = false 4977ec681f3Smrgif (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and 4987ec681f3Smrg (not with_platform_android or get_option('platform-sdk-version') >= 29) and 4997ec681f3Smrg (not with_platform_windows or not with_shared_glapi)) 5007ec681f3Smrg pre_args += '-DUSE_ELF_TLS' 5017ec681f3Smrg use_elf_tls = true 5027ec681f3Smrg 5037ec681f3Smrg if with_platform_android 5047ec681f3Smrg # By default the NDK compiler, at least, emits emutls references instead of 5057ec681f3Smrg # ELF TLS, even when building targeting newer API levels. Make it actually do 5067ec681f3Smrg # ELF TLS instead. 5077ec681f3Smrg c_args += '-fno-emulated-tls' 5087ec681f3Smrg cpp_args += '-fno-emulated-tls' 50901e04c3fSmrg endif 51001e04c3fSmrgendif 51101e04c3fSmrg 51201e04c3fSmrgif with_glx != 'disabled' 51301e04c3fSmrg if not (with_platform_x11 and with_any_opengl) 51401e04c3fSmrg error('Cannot build GLX support without X11 platform support and at least one OpenGL API') 5157ec681f3Smrg elif with_glx == 'gallium-xlib' 51601e04c3fSmrg if not with_gallium 51701e04c3fSmrg error('Gallium-xlib based GLX requires at least one gallium driver') 51801e04c3fSmrg elif not with_gallium_softpipe 51901e04c3fSmrg error('Gallium-xlib based GLX requires softpipe or llvmpipe.') 52001e04c3fSmrg elif with_dri 52101e04c3fSmrg error('gallium-xlib conflicts with any dri driver') 52201e04c3fSmrg endif 5237ec681f3Smrg elif with_glx == 'xlib' 52401e04c3fSmrg if with_dri 52501e04c3fSmrg error('xlib conflicts with any dri driver') 52601e04c3fSmrg endif 52701e04c3fSmrg elif with_glx == 'dri' 52853c12917Smaya if not with_shared_glapi 52901e04c3fSmrg error('dri based GLX requires shared-glapi') 53001e04c3fSmrg endif 53101e04c3fSmrg endif 53201e04c3fSmrgendif 53301e04c3fSmrg 53401e04c3fSmrgwith_glvnd = get_option('glvnd') 5357ec681f3Smrgglvnd_vendor_name = get_option('glvnd-vendor-name') 53601e04c3fSmrgif with_glvnd 5377ec681f3Smrg if with_platform_windows 5387ec681f3Smrg error('glvnd cannot be used on Windows') 5397ec681f3Smrg elif with_glx == 'xlib' or with_glx == 'gallium-xlib' 54001e04c3fSmrg error('Cannot build glvnd support for GLX that is not DRI based.') 54101e04c3fSmrg elif with_glx == 'disabled' and not with_egl 54201e04c3fSmrg error('glvnd requires DRI based GLX and/or EGL') 54301e04c3fSmrg endif 54453c12917Smaya if get_option('egl-lib-suffix') != '' 54553c12917Smaya error('''EGL lib suffix can't be used with libglvnd''') 54653c12917Smaya endif 54701e04c3fSmrgendif 54801e04c3fSmrg 54901e04c3fSmrgif with_vulkan_icd_dir == '' 55001e04c3fSmrg with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d') 55101e04c3fSmrgendif 55201e04c3fSmrg 5537ec681f3Smrg# GNU/Hurd includes egl_dri2, without drm. 55453c12917Smayawith_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or 55553c12917Smaya host_machine.system() == 'gnu') 55601e04c3fSmrg_dri3 = get_option('dri3') 5577ec681f3Smrgif _dri3 == 'true' 5587ec681f3Smrg _dri3 = 'enabled' 5597ec681f3Smrg warning('dri3 option "true" deprecated, please use "enabled" instead.') 5607ec681f3Smrgelif _dri3 == 'false' 5617ec681f3Smrg _dri3 = 'disabled' 5627ec681f3Smrg warning('dri3 option "false" deprecated, please use "disabled" instead.') 5637ec681f3Smrgendif 56401e04c3fSmrgif _dri3 == 'auto' 56501e04c3fSmrg with_dri3 = system_has_kms_drm and with_dri2 56601e04c3fSmrgelse 5677ec681f3Smrg with_dri3 = _dri3 == 'enabled' 56801e04c3fSmrgendif 56901e04c3fSmrg 57001e04c3fSmrgif with_any_vk and (with_platform_x11 and not with_dri3) 57101e04c3fSmrg error('Vulkan drivers require dri3 for X11 support') 57201e04c3fSmrgendif 57301e04c3fSmrgif with_dri 5747ec681f3Smrg if with_glx == 'disabled' and not with_egl and not with_gbm 5757ec681f3Smrg error('building dri drivers require at least one windowing system') 57601e04c3fSmrg endif 57701e04c3fSmrgendif 57801e04c3fSmrg 5797ec681f3Smrgif with_gallium_kmsro and (with_platform_x11 and not with_dri3) 5807ec681f3Smrg error('kmsro requires dri3 for X11 support') 5817ec681f3Smrgendif 58201e04c3fSmrg 58301e04c3fSmrg_vdpau = get_option('gallium-vdpau') 5847ec681f3Smrgif _vdpau == 'true' 5857ec681f3Smrg _vdpau = 'enabled' 5867ec681f3Smrg warning('gallium-vdpau option "true" deprecated, please use "enabled" instead.') 5877ec681f3Smrgelif _vdpau == 'false' 5887ec681f3Smrg _vdpau = 'disabled' 5897ec681f3Smrg warning('gallium-vdpau option "false" deprecated, please use "disabled" instead.') 5907ec681f3Smrgendif 59101e04c3fSmrgif not system_has_kms_drm 5927ec681f3Smrg if _vdpau == 'enabled' 59301e04c3fSmrg error('VDPAU state tracker can only be build on unix-like OSes.') 59401e04c3fSmrg else 5957ec681f3Smrg _vdpau = 'disabled' 59601e04c3fSmrg endif 59701e04c3fSmrgelif not with_platform_x11 5987ec681f3Smrg if _vdpau == 'enabled' 59901e04c3fSmrg error('VDPAU state tracker requires X11 support.') 60001e04c3fSmrg else 6017ec681f3Smrg _vdpau = 'disabled' 60201e04c3fSmrg endif 60301e04c3fSmrgelif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or 60401e04c3fSmrg with_gallium_nouveau) 6057ec681f3Smrg if _vdpau == 'enabled' 60601e04c3fSmrg error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.') 60701e04c3fSmrg else 6087ec681f3Smrg _vdpau = 'disabled' 60901e04c3fSmrg endif 61001e04c3fSmrgendif 61101e04c3fSmrgdep_vdpau = null_dep 61201e04c3fSmrgwith_gallium_vdpau = false 6137ec681f3Smrgif _vdpau != 'disabled' 6147ec681f3Smrg dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'enabled') 61501e04c3fSmrg if dep_vdpau.found() 6167ec681f3Smrg dep_vdpau = dep_vdpau.partial_dependency(compile_args : true) 61701e04c3fSmrg with_gallium_vdpau = true 61801e04c3fSmrg endif 61901e04c3fSmrgendif 62001e04c3fSmrg 62101e04c3fSmrgif with_gallium_vdpau 62201e04c3fSmrg pre_args += '-DHAVE_ST_VDPAU' 62301e04c3fSmrgendif 62401e04c3fSmrgvdpau_drivers_path = get_option('vdpau-libs-path') 62501e04c3fSmrgif vdpau_drivers_path == '' 62601e04c3fSmrg vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau') 62701e04c3fSmrgendif 62801e04c3fSmrg 6297ec681f3Smrgif with_gallium_zink 6307ec681f3Smrg dep_vulkan = dependency('vulkan') 6317ec681f3Smrgendif 6327ec681f3Smrg 6337ec681f3Smrgdep_dxheaders = null_dep 6347ec681f3Smrgif with_gallium_d3d12 or with_microsoft_clc 6357ec681f3Smrg dep_dxheaders = dependency('DirectX-Headers', fallback : ['DirectX-Headers', 'dep_dxheaders'], 6367ec681f3Smrg required : with_gallium_d3d12 6377ec681f3Smrg ) 6387ec681f3Smrgendif 6397ec681f3Smrg 6407ec681f3Smrgif with_vulkan_overlay_layer or with_aco_tests 6417ec681f3Smrg prog_glslang = find_program('glslangValidator') 6427ec681f3Smrgendif 6437ec681f3Smrg 64401e04c3fSmrg_xvmc = get_option('gallium-xvmc') 6457ec681f3Smrgif _xvmc == 'true' 6467ec681f3Smrg _xvmc = 'enabled' 6477ec681f3Smrg warning('gallium-xvmc option "true" deprecated, please use "enabled" instead.') 6487ec681f3Smrgelif _xvmc == 'false' 6497ec681f3Smrg _xvmc = 'disabled' 6507ec681f3Smrg warning('gallium-xvmc option "false" deprecated, please use "disabled" instead.') 6517ec681f3Smrgendif 65201e04c3fSmrgif not system_has_kms_drm 6537ec681f3Smrg if _xvmc == 'enabled' 65401e04c3fSmrg error('XVMC state tracker can only be build on unix-like OSes.') 65501e04c3fSmrg else 6567ec681f3Smrg _xvmc = 'disabled' 65701e04c3fSmrg endif 65801e04c3fSmrgelif not with_platform_x11 6597ec681f3Smrg if _xvmc == 'enabled' 66001e04c3fSmrg error('XVMC state tracker requires X11 support.') 66101e04c3fSmrg else 6627ec681f3Smrg _xvmc = 'disabled' 66301e04c3fSmrg endif 66401e04c3fSmrgelif not (with_gallium_r600 or with_gallium_nouveau) 6657ec681f3Smrg if _xvmc == 'enabled' 66601e04c3fSmrg error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.') 66701e04c3fSmrg else 6687ec681f3Smrg _xvmc = 'disabled' 66901e04c3fSmrg endif 67001e04c3fSmrgendif 67101e04c3fSmrgdep_xvmc = null_dep 6727ec681f3Smrgdep_xv = null_dep 67301e04c3fSmrgwith_gallium_xvmc = false 6747ec681f3Smrgif _xvmc != 'disabled' 6757ec681f3Smrg dep_xvmc = dependency('xvmc', version : '>= 1.0.6', required : _xvmc == 'enabled') 6767ec681f3Smrg dep_xv = dependency('xv', required : _xvmc == 'enabled') 6777ec681f3Smrg with_gallium_xvmc = dep_xvmc.found() and dep_xv.found() 67801e04c3fSmrgendif 67901e04c3fSmrg 68001e04c3fSmrgxvmc_drivers_path = get_option('xvmc-libs-path') 68101e04c3fSmrgif xvmc_drivers_path == '' 68201e04c3fSmrg xvmc_drivers_path = get_option('libdir') 68301e04c3fSmrgendif 68401e04c3fSmrg 68501e04c3fSmrg_omx = get_option('gallium-omx') 68601e04c3fSmrgif not system_has_kms_drm 68701e04c3fSmrg if ['auto', 'disabled'].contains(_omx) 68801e04c3fSmrg _omx = 'disabled' 68901e04c3fSmrg else 69001e04c3fSmrg error('OMX state tracker can only be built on unix-like OSes.') 69101e04c3fSmrg endif 69201e04c3fSmrgelif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau) 69301e04c3fSmrg if ['auto', 'disabled'].contains(_omx) 69401e04c3fSmrg _omx = 'disabled' 69501e04c3fSmrg else 69601e04c3fSmrg error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.') 69701e04c3fSmrg endif 69801e04c3fSmrgendif 69901e04c3fSmrgwith_gallium_omx = _omx 70001e04c3fSmrgdep_omx = null_dep 70101e04c3fSmrgdep_omx_other = [] 70201e04c3fSmrgif ['auto', 'bellagio'].contains(_omx) 70301e04c3fSmrg dep_omx = dependency( 70401e04c3fSmrg 'libomxil-bellagio', required : _omx == 'bellagio' 70501e04c3fSmrg ) 70601e04c3fSmrg if dep_omx.found() 70701e04c3fSmrg with_gallium_omx = 'bellagio' 70801e04c3fSmrg endif 70901e04c3fSmrgendif 71001e04c3fSmrgif ['auto', 'tizonia'].contains(_omx) 71101e04c3fSmrg if with_dri and with_egl 71201e04c3fSmrg dep_omx = dependency( 71301e04c3fSmrg 'libtizonia', version : '>= 0.10.0', 71401e04c3fSmrg required : _omx == 'tizonia', 71501e04c3fSmrg ) 71601e04c3fSmrg dep_omx_other = [ 71701e04c3fSmrg dependency('libtizplatform', required : _omx == 'tizonia'), 71801e04c3fSmrg dependency('tizilheaders', required : _omx == 'tizonia'), 71901e04c3fSmrg ] 72001e04c3fSmrg if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found() 72101e04c3fSmrg with_gallium_omx = 'tizonia' 72201e04c3fSmrg endif 72301e04c3fSmrg elif _omx == 'tizonia' 72401e04c3fSmrg error('OMX-Tizonia state tracker requires dri and egl') 72501e04c3fSmrg endif 72601e04c3fSmrgendif 72701e04c3fSmrgif _omx == 'auto' 72801e04c3fSmrg with_gallium_omx = 'disabled' 72901e04c3fSmrgelse 73001e04c3fSmrg with_gallium_omx = _omx 73101e04c3fSmrgendif 73201e04c3fSmrg 73301e04c3fSmrgpre_args += [ 73401e04c3fSmrg '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'), 73501e04c3fSmrg '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'), 73601e04c3fSmrg] 73701e04c3fSmrg 73801e04c3fSmrg 73901e04c3fSmrgomx_drivers_path = get_option('omx-libs-path') 74001e04c3fSmrg 74101e04c3fSmrgif with_gallium_omx != 'disabled' 74201e04c3fSmrg # Figure out where to put the omx driver. 74301e04c3fSmrg # FIXME: this could all be vastly simplified by adding a 'defined_variable' 74401e04c3fSmrg # argument to meson's get_pkgconfig_variable method. 74501e04c3fSmrg if omx_drivers_path == '' 74601e04c3fSmrg _omx_libdir = dep_omx.get_pkgconfig_variable('libdir') 74701e04c3fSmrg _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir') 74801e04c3fSmrg if _omx_libdir == get_option('libdir') 74901e04c3fSmrg omx_drivers_path = _omx_drivers_dir 75001e04c3fSmrg else 75101e04c3fSmrg _omx_base_dir = [] 75201e04c3fSmrg # This will fail on windows. Does OMX run on windows? 75301e04c3fSmrg _omx_libdir = _omx_libdir.split('/') 75401e04c3fSmrg _omx_drivers_dir = _omx_drivers_dir.split('/') 75501e04c3fSmrg foreach o : _omx_drivers_dir 75601e04c3fSmrg if not _omx_libdir.contains(o) 75701e04c3fSmrg _omx_base_dir += o 75801e04c3fSmrg endif 75901e04c3fSmrg endforeach 76001e04c3fSmrg omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir) 76101e04c3fSmrg endif 76201e04c3fSmrg endif 76301e04c3fSmrgendif 76401e04c3fSmrg 76501e04c3fSmrg_va = get_option('gallium-va') 7667ec681f3Smrgif _va == 'true' 7677ec681f3Smrg _va = 'enabled' 7687ec681f3Smrg warning('gallium-va option "true" deprecated, please use "enabled" instead.') 7697ec681f3Smrgelif _va == 'false' 7707ec681f3Smrg _va = 'disabled' 7717ec681f3Smrg warning('gallium-va option "false" deprecated, please use "disabled" instead.') 7727ec681f3Smrgendif 77301e04c3fSmrgif not system_has_kms_drm 7747ec681f3Smrg if _va == 'enabled' 77501e04c3fSmrg error('VA state tracker can only be built on unix-like OSes.') 77601e04c3fSmrg else 7777ec681f3Smrg _va = 'disabled' 77801e04c3fSmrg endif 77901e04c3fSmrgelif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau) 7807ec681f3Smrg if _va == 'enabled' 78101e04c3fSmrg error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.') 78201e04c3fSmrg else 7837ec681f3Smrg _va = 'disabled' 78401e04c3fSmrg endif 78501e04c3fSmrgendif 78601e04c3fSmrgwith_gallium_va = false 78701e04c3fSmrgdep_va = null_dep 7887ec681f3Smrgif _va != 'disabled' 7897ec681f3Smrg dep_va = dependency('libva', version : '>= 1.8.0', required : _va == 'enabled') 79001e04c3fSmrg if dep_va.found() 7917ec681f3Smrg dep_va_headers = dep_va.partial_dependency(compile_args : true) 79201e04c3fSmrg with_gallium_va = true 7937ec681f3Smrg if cc.has_header_symbol('va/va.h', 'VASurfaceAttribDRMFormatModifiers', 7947ec681f3Smrg dependencies: dep_va_headers) 7957ec681f3Smrg pre_args += '-DHAVE_VA_SURFACE_ATTRIB_DRM_FORMAT_MODIFIERS' 7967ec681f3Smrg endif 79701e04c3fSmrg endif 79801e04c3fSmrgendif 79901e04c3fSmrg 80001e04c3fSmrgva_drivers_path = get_option('va-libs-path') 80101e04c3fSmrgif va_drivers_path == '' 80201e04c3fSmrg va_drivers_path = join_paths(get_option('libdir'), 'dri') 80301e04c3fSmrgendif 80401e04c3fSmrg 80501e04c3fSmrg_xa = get_option('gallium-xa') 8067ec681f3Smrgif _xa == 'true' 8077ec681f3Smrg _xa = 'enabled' 8087ec681f3Smrg warning('gallium-xa option "true" deprecated, please use "enabled" instead.') 8097ec681f3Smrgelif _xa == 'false' 8107ec681f3Smrg _xa = 'disabled' 8117ec681f3Smrg warning('gallium-xa option "false" deprecated, please use "disabled" instead.') 8127ec681f3Smrgendif 81301e04c3fSmrgif not system_has_kms_drm 8147ec681f3Smrg if _xa == 'enabled' 81501e04c3fSmrg error('XA state tracker can only be built on unix-like OSes.') 81601e04c3fSmrg else 8177ec681f3Smrg _xa = 'disabled' 81801e04c3fSmrg endif 81901e04c3fSmrgelif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915 82001e04c3fSmrg or with_gallium_svga) 8217ec681f3Smrg if _xa == 'enabled' 82201e04c3fSmrg error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.') 82301e04c3fSmrg else 8247ec681f3Smrg _xa = 'disabled' 82501e04c3fSmrg endif 82601e04c3fSmrgendif 8277ec681f3Smrgwith_gallium_xa = _xa != 'disabled' 82801e04c3fSmrg 82901e04c3fSmrgd3d_drivers_path = get_option('d3d-drivers-path') 83001e04c3fSmrgif d3d_drivers_path == '' 831993e1d59Smrg d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d') 83201e04c3fSmrgendif 83301e04c3fSmrg 83401e04c3fSmrgwith_gallium_st_nine = get_option('gallium-nine') 83501e04c3fSmrgif with_gallium_st_nine 83601e04c3fSmrg if not with_gallium_softpipe 83701e04c3fSmrg error('The nine state tracker requires gallium softpipe/llvmpipe.') 83801e04c3fSmrg elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600 83953c12917Smaya or with_gallium_r300 or with_gallium_svga or with_gallium_i915 8407ec681f3Smrg or with_gallium_iris or with_gallium_crocus or with_gallium_zink) 84101e04c3fSmrg error('The nine state tracker requires at least one non-swrast gallium driver.') 84201e04c3fSmrg endif 84301e04c3fSmrg if not with_dri3 84401e04c3fSmrg error('Using nine with wine requires dri3') 84501e04c3fSmrg endif 84601e04c3fSmrgendif 8477ec681f3Smrgwith_gallium_st_d3d10umd = get_option('gallium-d3d10umd') 8487ec681f3Smrgif with_gallium_st_d3d10umd 8497ec681f3Smrg if not with_gallium_softpipe 8507ec681f3Smrg error('The d3d10umd state tracker requires gallium softpipe/llvmpipe.') 8517ec681f3Smrg endif 8527ec681f3Smrgendif 8537ec681f3Smrg_power8 = get_option('power8') 8547ec681f3Smrgif _power8 == 'true' 8557ec681f3Smrg _power8 = 'enabled' 8567ec681f3Smrg warning('power8 option "true" deprecated, please use "enabled" instead.') 8577ec681f3Smrgelif _power8 == 'false' 8587ec681f3Smrg _power8 = 'disabled' 8597ec681f3Smrg warning('power8 option "false" deprecated, please use "disabled" instead.') 8607ec681f3Smrgendif 8617ec681f3Smrgif _power8 != 'disabled' 86201e04c3fSmrg # on old versions of meson the cpu family would return as ppc64le on little 86301e04c3fSmrg # endian power8, this was changed in 0.48 such that the family would always 8647ec681f3Smrg # be ppc64 regardless of endianness, and then the machine.endian() value 86501e04c3fSmrg # should be checked. Since we support versions < 0.48 we need to use 86601e04c3fSmrg # startswith. 86701e04c3fSmrg if host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little' 86801e04c3fSmrg if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8') 86901e04c3fSmrg error('Altivec is not supported with gcc version < 4.8.') 87001e04c3fSmrg endif 87101e04c3fSmrg if cc.compiles(''' 87201e04c3fSmrg #include <altivec.h> 87301e04c3fSmrg int main() { 87401e04c3fSmrg vector unsigned char r; 87501e04c3fSmrg vector unsigned int v = vec_splat_u32 (1); 87601e04c3fSmrg r = __builtin_vec_vgbbd ((vector unsigned char) v); 87701e04c3fSmrg return 0; 87801e04c3fSmrg }''', 87901e04c3fSmrg args : '-mpower8-vector', 88001e04c3fSmrg name : 'POWER8 intrinsics') 88101e04c3fSmrg pre_args += ['-D_ARCH_PWR8', '-mpower8-vector'] 8827ec681f3Smrg elif get_option('power8') == 'enabled' 88301e04c3fSmrg error('POWER8 intrinsic support required but not found.') 88401e04c3fSmrg endif 88501e04c3fSmrg endif 88601e04c3fSmrgendif 88701e04c3fSmrg 8887ec681f3Smrgif get_option('vmware-mks-stats') 8897ec681f3Smrg if not with_gallium_svga 8907ec681f3Smrg error('vmware-mks-stats requires gallium VMware/svga driver.') 8917ec681f3Smrg endif 8927ec681f3Smrg pre_args += '-DVMX86_STATS=1' 8937ec681f3Smrgendif 8947ec681f3Smrg 89501e04c3fSmrg_opencl = get_option('gallium-opencl') 89601e04c3fSmrgif _opencl != 'disabled' 89701e04c3fSmrg if not with_gallium 89801e04c3fSmrg error('OpenCL Clover implementation requires at least one gallium driver.') 89901e04c3fSmrg endif 90001e04c3fSmrg 9017ec681f3Smrg with_libclc = true 90201e04c3fSmrg with_gallium_opencl = true 90301e04c3fSmrg with_opencl_icd = _opencl == 'icd' 90401e04c3fSmrgelse 90501e04c3fSmrg with_gallium_opencl = false 90601e04c3fSmrg with_opencl_icd = false 90701e04c3fSmrgendif 90801e04c3fSmrg 9097ec681f3Smrgdep_clc = null_dep 9107ec681f3Smrgif with_libclc 9117ec681f3Smrg dep_clc = dependency('libclc') 9127ec681f3Smrgendif 9137ec681f3Smrg 91401e04c3fSmrggl_pkgconfig_c_flags = [] 91501e04c3fSmrgif with_platform_x11 91601e04c3fSmrg if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm') 91701e04c3fSmrg pre_args += '-DHAVE_X11_PLATFORM' 9187ec681f3Smrg pre_args += '-DHAVE_XCB_PLATFORM' 91901e04c3fSmrg endif 92001e04c3fSmrg if with_glx == 'xlib' or with_glx == 'gallium-xlib' 92101e04c3fSmrg pre_args += '-DUSE_XSHM' 92201e04c3fSmrg else 92301e04c3fSmrg pre_args += '-DGLX_INDIRECT_RENDERING' 92401e04c3fSmrg if with_glx_direct 92501e04c3fSmrg pre_args += '-DGLX_DIRECT_RENDERING' 92601e04c3fSmrg endif 92701e04c3fSmrg if with_dri_platform == 'drm' 92801e04c3fSmrg pre_args += '-DGLX_USE_DRM' 92901e04c3fSmrg elif with_dri_platform == 'apple' 93001e04c3fSmrg pre_args += '-DGLX_USE_APPLEGL' 93101e04c3fSmrg elif with_dri_platform == 'windows' 93201e04c3fSmrg pre_args += '-DGLX_USE_WINDOWSGL' 93301e04c3fSmrg endif 93401e04c3fSmrg endif 93501e04c3fSmrgelse 9367ec681f3Smrg pre_args += '-DEGL_NO_X11' 9377ec681f3Smrg gl_pkgconfig_c_flags += '-DEGL_NO_X11' 93801e04c3fSmrgendif 9397ec681f3Smrgif with_gbm and not with_platform_android 94001e04c3fSmrg pre_args += '-DHAVE_DRM_PLATFORM' 94101e04c3fSmrgendif 9427ec681f3Smrgif with_platform_windows 9437ec681f3Smrg pre_args += '-DHAVE_WINDOWS_PLATFORM' 9447ec681f3Smrgendif 9457ec681f3Smrg 9467ec681f3Smrgwith_android_stub = get_option('android-stub') 9477ec681f3Smrgif with_android_stub and not with_platform_android 9487ec681f3Smrg error('`-D android-stub=true` makes no sense without `-D platforms=android`') 94901e04c3fSmrgendif 9507ec681f3Smrg 95101e04c3fSmrgif with_platform_android 9527ec681f3Smrg dep_android_mapper4 = null_dep 9537ec681f3Smrg if not with_android_stub 9547ec681f3Smrg dep_android = [ 9557ec681f3Smrg dependency('cutils'), 9567ec681f3Smrg dependency('hardware'), 9577ec681f3Smrg dependency('sync'), 9587ec681f3Smrg dependency('backtrace') 9597ec681f3Smrg ] 9607ec681f3Smrg if get_option('platform-sdk-version') >= 26 9617ec681f3Smrg dep_android += dependency('nativewindow') 9627ec681f3Smrg endif 9637ec681f3Smrg if get_option('platform-sdk-version') >= 30 9647ec681f3Smrg dep_android_mapper4 = dependency('android.hardware.graphics.mapper', version : '>= 4.0', required : false) 9657ec681f3Smrg endif 96653c12917Smaya endif 9677ec681f3Smrg pre_args += [ 9687ec681f3Smrg '-DHAVE_ANDROID_PLATFORM', 9697ec681f3Smrg '-DANDROID', 9707ec681f3Smrg '-DANDROID_API_LEVEL=' + get_option('platform-sdk-version').to_string() 9717ec681f3Smrg ] 97201e04c3fSmrgendif 97301e04c3fSmrgif with_platform_haiku 97401e04c3fSmrg pre_args += '-DHAVE_HAIKU_PLATFORM' 97501e04c3fSmrgendif 97601e04c3fSmrg 9777ec681f3Smrgprog_python = import('python').find_installation('python3') 97801e04c3fSmrghas_mako = run_command( 97901e04c3fSmrg prog_python, '-c', 98001e04c3fSmrg ''' 98101e04c3fSmrgfrom distutils.version import StrictVersion 98201e04c3fSmrgimport mako 98301e04c3fSmrgassert StrictVersion(mako.__version__) > StrictVersion("0.8.0") 98401e04c3fSmrg ''') 98501e04c3fSmrgif has_mako.returncode() != 0 98601e04c3fSmrg error('Python (3.x) mako module >= 0.8.0 required to build mesa.') 98701e04c3fSmrgendif 98801e04c3fSmrg 98901e04c3fSmrgif cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6') 99001e04c3fSmrg error('When using GCC, version 4.4.6 or later is required.') 99101e04c3fSmrgendif 99201e04c3fSmrg 9937ec681f3Smrg# Support systems without ETIME (e.g. FreeBSD) 9947ec681f3Smrgif cc.get_define('ETIME', prefix : '#include <errno.h>') == '' 9957ec681f3Smrg pre_args += '-DETIME=ETIMEDOUT' 9967ec681f3Smrgendif 9977ec681f3Smrg 99801e04c3fSmrg# Define DEBUG for debug builds only (debugoptimized is not included on this one) 99901e04c3fSmrgif get_option('buildtype') == 'debug' 100001e04c3fSmrg pre_args += '-DDEBUG' 100101e04c3fSmrgendif 100201e04c3fSmrg 100353c12917Smayawith_shader_cache = false 100453c12917Smaya_shader_cache = get_option('shader-cache') 10057ec681f3Smrgif _shader_cache == 'true' 10067ec681f3Smrg _shader_cache = 'enabled' 10077ec681f3Smrg warning('shader_cache option "true" deprecated, please use "enabled" instead.') 10087ec681f3Smrgelif _shader_cache == 'false' 10097ec681f3Smrg _shader_cache = 'disabled' 10107ec681f3Smrg warning('shader_cache option "false" deprecated, please use "disabled" instead.') 10117ec681f3Smrgendif 10127ec681f3Smrgif _shader_cache != 'disabled' 101353c12917Smaya if host_machine.system() == 'windows' 10147ec681f3Smrg if _shader_cache == 'enabled' 101553c12917Smaya error('Shader Cache does not currently work on Windows') 101653c12917Smaya endif 101753c12917Smaya else 101853c12917Smaya pre_args += '-DENABLE_SHADER_CACHE' 10197ec681f3Smrg if not get_option('shader-cache-default') 10207ec681f3Smrg pre_args += '-DSHADER_CACHE_DISABLE_BY_DEFAULT' 10217ec681f3Smrg endif 102253c12917Smaya with_shader_cache = true 102353c12917Smaya endif 102453c12917Smayaendif 10257ec681f3Smrg 10267ec681f3Smrgif with_shader_cache 10277ec681f3Smrg shader_cache_max_size = get_option('shader-cache-max-size') 10287ec681f3Smrg if shader_cache_max_size != '' 10297ec681f3Smrg pre_args += '-DMESA_GLSL_CACHE_MAX_SIZE="@0@"'.format(shader_cache_max_size) 10307ec681f3Smrg endif 103101e04c3fSmrgendif 103201e04c3fSmrg 103301e04c3fSmrg# Check for GCC style builtins 103401e04c3fSmrgforeach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs', 10357ec681f3Smrg 'ffsll', 'popcount', 'popcountll', 'unreachable', 'types_compatible_p'] 103601e04c3fSmrg if cc.has_function(b) 103701e04c3fSmrg pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper()) 103801e04c3fSmrg endif 103901e04c3fSmrgendforeach 104001e04c3fSmrg 104101e04c3fSmrg# check for GCC __attribute__ 10427ec681f3Smrg_attributes = [ 10437ec681f3Smrg 'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result', 10447ec681f3Smrg 'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn', 10457ec681f3Smrg] 10467ec681f3Smrgforeach a : cc.get_supported_function_attributes(_attributes) 10477ec681f3Smrg pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper()) 104801e04c3fSmrgendforeach 10497ec681f3Smrgif cc.has_function_attribute('visibility:hidden') 105001e04c3fSmrg pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY' 105101e04c3fSmrgendif 10527ec681f3Smrgif cc.compiles('__uint128_t foo(void) { return 0; }', 10537ec681f3Smrg name : '__uint128_t') 10547ec681f3Smrg pre_args += '-DHAVE_UINT128' 105501e04c3fSmrgendif 105601e04c3fSmrg 105701e04c3fSmrg# TODO: this is very incomplete 10587ec681f3Smrgif ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku'].contains(host_machine.system()) 105901e04c3fSmrg pre_args += '-D_GNU_SOURCE' 10607ec681f3Smrgelif host_machine.system() == 'sunos' 10617ec681f3Smrg pre_args += '-D__EXTENSIONS__' 10627ec681f3Smrgelif host_machine.system() == 'windows' 10637ec681f3Smrg pre_args += [ 10647ec681f3Smrg '-D_WINDOWS', '-D_WIN32_WINNT=0x0A00', '-DWINVER=0x0A00', 10657ec681f3Smrg '-DPIPE_SUBSYSTEM_WINDOWS_USER', 10667ec681f3Smrg '-D_USE_MATH_DEFINES', # XXX: scons didn't use this for mingw 10677ec681f3Smrg ] 10687ec681f3Smrg if cc.get_id() == 'msvc' 10697ec681f3Smrg pre_args += [ 10707ec681f3Smrg '-DVC_EXTRALEAN', 10717ec681f3Smrg '-D_CRT_SECURE_NO_WARNINGS', 10727ec681f3Smrg '-D_CRT_SECURE_NO_DEPRECATE', 10737ec681f3Smrg '-D_SCL_SECURE_NO_WARNINGS', 10747ec681f3Smrg '-D_SCL_SECURE_NO_DEPRECATE', 10757ec681f3Smrg '-D_ALLOW_KEYWORD_MACROS', 10767ec681f3Smrg '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions 10777ec681f3Smrg '-DNOMINMAX', 10787ec681f3Smrg ] 10797ec681f3Smrg else 10807ec681f3Smrg pre_args += ['-D__MSVCRT_VERSION__=0x0700'] 10817ec681f3Smrg endif 10827ec681f3Smrgelif host_machine.system() == 'openbsd' 10837ec681f3Smrg pre_args += '-D_ISOC11_SOURCE' 108401e04c3fSmrgendif 108501e04c3fSmrg 108601e04c3fSmrg# Check for generic C arguments 10877ec681f3Smrgc_msvc_compat_args = [] 10887ec681f3Smrgno_override_init_args = [] 10897ec681f3Smrgcpp_msvc_compat_args = [] 10907ec681f3Smrgif cc.get_id() == 'msvc' 10917ec681f3Smrg foreach a : ['/wd4018', # signed/unsigned mismatch 10927ec681f3Smrg '/wd4056', # overflow in floating-point constant arithmetic 10937ec681f3Smrg '/wd4244', # conversion from 'type1' to 'type2', possible loss of data 10947ec681f3Smrg '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data 10957ec681f3Smrg '/wd4305', # trancation from 'type1' to 'type2' 10967ec681f3Smrg '/wd4351', # new behavior: elements of array 'array' will be default initialized 10977ec681f3Smrg '/wd4756', # overflow in constant arithmetic 10987ec681f3Smrg '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) 10997ec681f3Smrg '/wd4996', # disabled deprecated POSIX name warnings 11007ec681f3Smrg '/wd4291', # no matching operator delete found 11017ec681f3Smrg '/wd4146', # unary minus operator applied to unsigned type, result still unsigned 11027ec681f3Smrg '/wd4200', # nonstandard extension used: zero-sized array in struct/union 11037ec681f3Smrg '/wd4624', # destructor was implicitly defined as deleted [from LLVM] 11047ec681f3Smrg '/wd4309', # 'initializing': truncation of constant value 11057ec681f3Smrg '/wd4838', # conversion from 'int' to 'const char' requires a narrowing conversion 11067ec681f3Smrg '/wd5105', # macro expansion producing 'defined' has undefined behavior (winbase.h, need Windows SDK upgrade) 11077ec681f3Smrg '/we4020', # Error when passing the wrong number of parameters 11087ec681f3Smrg '/we4024', # Error when passing different type of parameter 11097ec681f3Smrg '/Zc:__cplusplus', #Set __cplusplus macro to match the /std:c++<version> on the command line 11107ec681f3Smrg ] 11117ec681f3Smrg if cc.has_argument(a) 11127ec681f3Smrg c_args += a 11137ec681f3Smrg endif 11147ec681f3Smrg if cpp.has_argument(a) 11157ec681f3Smrg cpp_args += a 11167ec681f3Smrg endif 11177ec681f3Smrg endforeach 11187ec681f3Smrgelse 11197ec681f3Smrg _trial = [ 11207ec681f3Smrg '-Werror=implicit-function-declaration', 11217ec681f3Smrg '-Werror=missing-prototypes', 11227ec681f3Smrg '-Werror=return-type', 11237ec681f3Smrg '-Werror=empty-body', 11247ec681f3Smrg '-Werror=incompatible-pointer-types', 11257ec681f3Smrg '-Werror=int-conversion', 11267ec681f3Smrg '-Wimplicit-fallthrough', 11277ec681f3Smrg '-Wno-missing-field-initializers', 11287ec681f3Smrg '-Wno-format-truncation', 11297ec681f3Smrg '-fno-math-errno', 11307ec681f3Smrg '-fno-trapping-math', 11317ec681f3Smrg '-Qunused-arguments', 11327ec681f3Smrg '-fno-common', 11337ec681f3Smrg ] 11347ec681f3Smrg # MinGW chokes on format specifiers and I can't get it all working 11357ec681f3Smrg if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows') 11367ec681f3Smrg _trial += ['-Werror=format', '-Wformat-security'] 113701e04c3fSmrg endif 11387ec681f3Smrg # FreeBSD annotated <pthread.h> but Mesa isn't ready 11397ec681f3Smrg if not (cc.get_id() == 'clang' and host_machine.system() == 'freebsd') 11407ec681f3Smrg _trial += ['-Werror=thread-safety'] 114101e04c3fSmrg endif 11427ec681f3Smrg foreach a : _trial 11437ec681f3Smrg if cc.has_argument(a) 11447ec681f3Smrg c_args += a 11457ec681f3Smrg endif 11467ec681f3Smrg endforeach 11477ec681f3Smrg 11487ec681f3Smrg _trial = [ 11497ec681f3Smrg '-Werror=return-type', 11507ec681f3Smrg '-Werror=empty-body', 11517ec681f3Smrg '-Wno-non-virtual-dtor', 11527ec681f3Smrg '-Wno-missing-field-initializers', 11537ec681f3Smrg '-Wno-format-truncation', 11547ec681f3Smrg '-fno-math-errno', 11557ec681f3Smrg '-fno-trapping-math', 11567ec681f3Smrg '-Qunused-arguments', 11577ec681f3Smrg # Some classes use custom new operator which zeroes memory, however 11587ec681f3Smrg # gcc does aggressive dead-store elimination which threats all writes 11597ec681f3Smrg # to the memory before the constructor as "dead stores". 11607ec681f3Smrg # For now we disable this optimization. 11617ec681f3Smrg '-flifetime-dse=1', 11627ec681f3Smrg ] 11637ec681f3Smrg # MinGW chokes on format specifiers and I can't get it all working 11647ec681f3Smrg if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows') 11657ec681f3Smrg _trial += ['-Werror=format', '-Wformat-security'] 116601e04c3fSmrg endif 11677ec681f3Smrg foreach a : _trial 11687ec681f3Smrg if cpp.has_argument(a) 11697ec681f3Smrg cpp_args += a 11707ec681f3Smrg endif 11717ec681f3Smrg endforeach 117201e04c3fSmrg 11737ec681f3Smrg foreach a : ['-Wno-override-init', '-Wno-initializer-overrides'] 11747ec681f3Smrg if cc.has_argument(a) 11757ec681f3Smrg no_override_init_args += a 11767ec681f3Smrg endif 11777ec681f3Smrg endforeach 11787ec681f3Smrg 11797ec681f3Smrg # Check for C and C++ arguments for MSVC compatibility. These are only used 11807ec681f3Smrg # in parts of the mesa code base that need to compile with MSVC, mainly 11817ec681f3Smrg # common code 11827ec681f3Smrg foreach a : ['-Werror=pointer-arith', '-Werror=gnu-empty-initializer'] 11837ec681f3Smrg if cc.has_argument(a) 11847ec681f3Smrg c_msvc_compat_args += a 11857ec681f3Smrg endif 11867ec681f3Smrg if cpp.has_argument(a) 11877ec681f3Smrg cpp_msvc_compat_args += a 11887ec681f3Smrg endif 11897ec681f3Smrg endforeach 119001e04c3fSmrg 11917ec681f3Smrg if cc.has_argument('-Wmicrosoft-enum-value') # Clang 11927ec681f3Smrg c_args += '-Wno-microsoft-enum-value' 11937ec681f3Smrg cpp_args += '-Wno-microsoft-enum-value' 119401e04c3fSmrg endif 119501e04c3fSmrgendif 119601e04c3fSmrg 11977ec681f3Smrg# set linker arguments 11987ec681f3Smrgif host_machine.system() == 'windows' 11997ec681f3Smrg if cc.get_id() == 'msvc' 12007ec681f3Smrg add_project_link_arguments( 12017ec681f3Smrg '/fixed:no', 12027ec681f3Smrg '/dynamicbase', 12037ec681f3Smrg '/nxcompat', 12047ec681f3Smrg language : ['c', 'cpp'], 12057ec681f3Smrg ) 12067ec681f3Smrg if get_option('buildtype') != 'debug' 12077ec681f3Smrg add_project_link_arguments( 12087ec681f3Smrg '/incremental:no', 12097ec681f3Smrg language : ['c', 'cpp'], 12107ec681f3Smrg ) 12117ec681f3Smrg endif 12127ec681f3Smrg else 12137ec681f3Smrg add_project_link_arguments( 12147ec681f3Smrg cc.get_supported_link_arguments( 12157ec681f3Smrg '-Wl,--nxcompat', 12167ec681f3Smrg '-Wl,--dynamicbase', 12177ec681f3Smrg '-static-libgcc', 12187ec681f3Smrg '-static-libstdc++', 12197ec681f3Smrg ), 12207ec681f3Smrg language : ['c'], 12217ec681f3Smrg ) 12227ec681f3Smrg add_project_link_arguments( 12237ec681f3Smrg cpp.get_supported_link_arguments( 12247ec681f3Smrg '-Wl,--nxcompat', 12257ec681f3Smrg '-Wl,--dynamicbase', 12267ec681f3Smrg '-static-libgcc', 12277ec681f3Smrg '-static-libstdc++', 12287ec681f3Smrg ), 12297ec681f3Smrg language : ['cpp'], 12307ec681f3Smrg ) 123101e04c3fSmrg endif 12327ec681f3Smrgendif 123301e04c3fSmrg 12347ec681f3Smrgif host_machine.cpu_family().startswith('x86') and cc.get_id() != 'msvc' 123501e04c3fSmrg pre_args += '-DUSE_SSE41' 123601e04c3fSmrg with_sse41 = true 123701e04c3fSmrg sse41_args = ['-msse4.1'] 123801e04c3fSmrg 123901e04c3fSmrg if host_machine.cpu_family() == 'x86' 12407ec681f3Smrg if get_option('sse2') 12417ec681f3Smrg # These settings make generated GCC code match MSVC and follow 12427ec681f3Smrg # GCC advice on https://gcc.gnu.org/wiki/FloatingPointMath#x86note 12437ec681f3Smrg # 12447ec681f3Smrg # NOTE: We need to ensure stack is realigned given that we 12457ec681f3Smrg # produce shared objects, and have no control over the stack 12467ec681f3Smrg # alignment policy of the application. Therefore we need 12477ec681f3Smrg # -mstackrealign or -mincoming-stack-boundary=2. 12487ec681f3Smrg # 12497ec681f3Smrg # XXX: We could have SSE without -mstackrealign if we always used 12507ec681f3Smrg # __attribute__((force_align_arg_pointer)), but that's not 12517ec681f3Smrg # always the case. 12527ec681f3Smrg c_args += ['-msse2', '-mfpmath=sse', '-mstackrealign'] 12537ec681f3Smrg else 12547ec681f3Smrg # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but 12557ec681f3Smrg # that's not guaranteed 12567ec681f3Smrg sse41_args += '-mstackrealign' 12577ec681f3Smrg endif 125801e04c3fSmrg endif 125901e04c3fSmrgelse 126001e04c3fSmrg with_sse41 = false 126101e04c3fSmrg sse41_args = [] 126201e04c3fSmrgendif 126301e04c3fSmrg 126401e04c3fSmrg# Check for GCC style atomics 126501e04c3fSmrgdep_atomic = null_dep 126601e04c3fSmrg 126701e04c3fSmrgif cc.compiles('''#include <stdint.h> 126801e04c3fSmrg int main() { 126901e04c3fSmrg struct { 127001e04c3fSmrg uint64_t *v; 127101e04c3fSmrg } x; 127201e04c3fSmrg return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & 127301e04c3fSmrg (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); 127401e04c3fSmrg 127501e04c3fSmrg }''', 127601e04c3fSmrg name : 'GCC atomic builtins') 127701e04c3fSmrg pre_args += '-DUSE_GCC_ATOMIC_BUILTINS' 127801e04c3fSmrg 127901e04c3fSmrg # Not all atomic calls can be turned into lock-free instructions, in which 128001e04c3fSmrg # GCC will make calls into the libatomic library. Check whether we need to 128101e04c3fSmrg # link with -latomic. 128201e04c3fSmrg # 128301e04c3fSmrg # This can happen for 64-bit atomic operations on 32-bit architectures such 128401e04c3fSmrg # as ARM. 128501e04c3fSmrg if not cc.links('''#include <stdint.h> 128601e04c3fSmrg int main() { 128701e04c3fSmrg struct { 128801e04c3fSmrg uint64_t *v; 128901e04c3fSmrg } x; 129001e04c3fSmrg return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) & 129101e04c3fSmrg (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL); 129201e04c3fSmrg }''', 129301e04c3fSmrg name : 'GCC atomic builtins required -latomic') 129401e04c3fSmrg dep_atomic = cc.find_library('atomic') 129501e04c3fSmrg endif 129601e04c3fSmrgendif 129701e04c3fSmrgif not cc.links('''#include <stdint.h> 129801e04c3fSmrg uint64_t v; 129901e04c3fSmrg int main() { 130001e04c3fSmrg return __sync_add_and_fetch(&v, (uint64_t)1); 130101e04c3fSmrg }''', 130201e04c3fSmrg dependencies : dep_atomic, 130301e04c3fSmrg name : 'GCC 64bit atomics') 130401e04c3fSmrg pre_args += '-DMISSING_64BIT_ATOMICS' 130501e04c3fSmrgendif 130601e04c3fSmrg 13077ec681f3Smrgdep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows) 130801e04c3fSmrg 13097ec681f3Smrg# TODO: shared/static? Is this even worth doing? 131001e04c3fSmrg 131101e04c3fSmrgwith_asm_arch = '' 13127ec681f3Smrgif host_machine.cpu_family() == 'x86' 13137ec681f3Smrg if system_has_kms_drm or host_machine.system() == 'gnu' 13147ec681f3Smrg with_asm_arch = 'x86' 13157ec681f3Smrg pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM', 13167ec681f3Smrg '-DUSE_SSE_ASM'] 13177ec681f3Smrg 13187ec681f3Smrg if with_glx_read_only_text 13197ec681f3Smrg pre_args += ['-DGLX_X86_READONLY_TEXT'] 132001e04c3fSmrg endif 132101e04c3fSmrg endif 13227ec681f3Smrgelif host_machine.cpu_family() == 'x86_64' 13237ec681f3Smrg if system_has_kms_drm 13247ec681f3Smrg with_asm_arch = 'x86_64' 13257ec681f3Smrg pre_args += ['-DUSE_X86_64_ASM'] 13267ec681f3Smrg endif 13277ec681f3Smrgelif host_machine.cpu_family() == 'arm' 13287ec681f3Smrg if system_has_kms_drm 13297ec681f3Smrg with_asm_arch = 'arm' 13307ec681f3Smrg pre_args += ['-DUSE_ARM_ASM'] 13317ec681f3Smrg endif 13327ec681f3Smrgelif host_machine.cpu_family() == 'aarch64' 13337ec681f3Smrg if system_has_kms_drm 13347ec681f3Smrg with_asm_arch = 'aarch64' 13357ec681f3Smrg pre_args += ['-DUSE_AARCH64_ASM'] 13367ec681f3Smrg endif 13377ec681f3Smrgelif host_machine.cpu_family() == 'sparc64' 13387ec681f3Smrg if system_has_kms_drm 13397ec681f3Smrg with_asm_arch = 'sparc' 13407ec681f3Smrg pre_args += ['-DUSE_SPARC_ASM'] 13417ec681f3Smrg endif 13427ec681f3Smrgelif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little' 13437ec681f3Smrg if system_has_kms_drm 13447ec681f3Smrg with_asm_arch = 'ppc64le' 13457ec681f3Smrg pre_args += ['-DUSE_PPC64LE_ASM'] 13467ec681f3Smrg endif 13477ec681f3Smrgelif host_machine.cpu_family() == 'mips64' and host_machine.endian() == 'little' 13487ec681f3Smrg if system_has_kms_drm 13497ec681f3Smrg with_asm_arch = 'mips64el' 13507ec681f3Smrg pre_args += ['-DUSE_MIPS64EL_ASM'] 13517ec681f3Smrg endif 135201e04c3fSmrgendif 135301e04c3fSmrg 135401e04c3fSmrg# Check for standard headers and functions 13557ec681f3Smrgif (cc.has_header_symbol('sys/sysmacros.h', 'major') and 13567ec681f3Smrg cc.has_header_symbol('sys/sysmacros.h', 'minor') and 13577ec681f3Smrg cc.has_header_symbol('sys/sysmacros.h', 'makedev')) 135801e04c3fSmrg pre_args += '-DMAJOR_IN_SYSMACROS' 13597ec681f3Smrgendif 13607ec681f3Smrgif (cc.has_header_symbol('sys/mkdev.h', 'major') and 13617ec681f3Smrg cc.has_header_symbol('sys/mkdev.h', 'minor') and 13627ec681f3Smrg cc.has_header_symbol('sys/mkdev.h', 'makedev')) 136301e04c3fSmrg pre_args += '-DMAJOR_IN_MKDEV' 136401e04c3fSmrgendif 136501e04c3fSmrg 13667ec681f3Smrgif cc.check_header('sched.h') 13677ec681f3Smrg pre_args += '-DHAS_SCHED_H' 13687ec681f3Smrg if cc.has_function('sched_getaffinity') 13697ec681f3Smrg pre_args += '-DHAS_SCHED_GETAFFINITY' 13707ec681f3Smrg endif 13717ec681f3Smrgendif 13727ec681f3Smrg 13737ec681f3Smrgif not ['linux'].contains(host_machine.system()) 13747ec681f3Smrg # Deprecated on Linux and requires <sys/types.h> on FreeBSD and OpenBSD 13757ec681f3Smrg if cc.check_header('sys/sysctl.h', prefix : '#include <sys/types.h>') 13767ec681f3Smrg pre_args += '-DHAVE_SYS_SYSCTL_H' 13777ec681f3Smrg endif 13787ec681f3Smrgendif 13797ec681f3Smrg 13807ec681f3Smrgforeach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h', 'cet.h', 'pthread_np.h'] 13817ec681f3Smrg if cc.check_header(h) 138201e04c3fSmrg pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify()) 138301e04c3fSmrg endif 138401e04c3fSmrgendforeach 138501e04c3fSmrg 13867ec681f3Smrgforeach f : ['strtof', 'mkostemp', 'timespec_get', 'memfd_create', 'random_r', 13877ec681f3Smrg 'flock', 'strtok_r', 'getrandom', 'qsort_r', 'qsort_s'] 138801e04c3fSmrg if cc.has_function(f) 138901e04c3fSmrg pre_args += '-DHAVE_@0@'.format(f.to_upper()) 139001e04c3fSmrg endif 139101e04c3fSmrgendforeach 139201e04c3fSmrg 139353c12917Smayaif cc.has_header_symbol('errno.h', 'program_invocation_name', 139453c12917Smaya args : '-D_GNU_SOURCE') 139553c12917Smaya pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME' 139653c12917Smayaelif with_tools.contains('intel') 139753c12917Smaya error('Intel tools require the program_invocation_name variable') 139853c12917Smayaendif 139953c12917Smaya 14007ec681f3Smrg# MinGW provides a __builtin_posix_memalign function, but not a posix_memalign. 14017ec681f3Smrg# This means that this check will succeed, but then compilation will later 14027ec681f3Smrg# fail. MSVC doesn't have this function at all, so only check for it on 14037ec681f3Smrg# non-windows platforms. 14047ec681f3Smrgif host_machine.system() != 'windows' 14057ec681f3Smrg if cc.has_function('posix_memalign') 14067ec681f3Smrg pre_args += '-DHAVE_POSIX_MEMALIGN' 14077ec681f3Smrg endif 14087ec681f3Smrgendif 14097ec681f3Smrg 14107ec681f3Smrgif cc.has_member('struct dirent', 'd_type', prefix: '''#include <sys/types.h> 14117ec681f3Smrg #include <dirent.h>''') 14127ec681f3Smrg pre_args += '-DHAVE_DIRENT_D_TYPE' 14137ec681f3Smrgendif 14147ec681f3Smrg 141501e04c3fSmrg# strtod locale support 141601e04c3fSmrgif cc.links(''' 141701e04c3fSmrg #define _GNU_SOURCE 141801e04c3fSmrg #include <stdlib.h> 141901e04c3fSmrg #include <locale.h> 142001e04c3fSmrg #ifdef HAVE_XLOCALE_H 142101e04c3fSmrg #include <xlocale.h> 142201e04c3fSmrg #endif 142301e04c3fSmrg int main() { 142401e04c3fSmrg locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL); 142501e04c3fSmrg const char *s = "1.0"; 142601e04c3fSmrg char *end; 142701e04c3fSmrg double d = strtod_l(s, end, loc); 142801e04c3fSmrg float f = strtof_l(s, end, loc); 142901e04c3fSmrg freelocale(loc); 143001e04c3fSmrg return 0; 143101e04c3fSmrg }''', 143201e04c3fSmrg args : pre_args, 143301e04c3fSmrg name : 'strtod has locale support') 143401e04c3fSmrg pre_args += '-DHAVE_STRTOD_L' 143501e04c3fSmrgendif 143601e04c3fSmrg 143701e04c3fSmrg# Check for some linker flags 143801e04c3fSmrgld_args_bsymbolic = [] 143901e04c3fSmrgif cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic') 144001e04c3fSmrg ld_args_bsymbolic += '-Wl,-Bsymbolic' 144101e04c3fSmrgendif 144201e04c3fSmrgld_args_gc_sections = [] 144301e04c3fSmrgif cc.links('static char unused() { return 5; } int main() { return 0; }', 144401e04c3fSmrg args : '-Wl,--gc-sections', name : 'gc-sections') 144501e04c3fSmrg ld_args_gc_sections += '-Wl,--gc-sections' 144601e04c3fSmrgendif 144701e04c3fSmrgwith_ld_version_script = false 144801e04c3fSmrgif cc.links('int main() { return 0; }', 144901e04c3fSmrg args : '-Wl,--version-script=@0@'.format( 145001e04c3fSmrg join_paths(meson.source_root(), 'build-support/conftest.map')), 145101e04c3fSmrg name : 'version-script') 145201e04c3fSmrg with_ld_version_script = true 145301e04c3fSmrgendif 145401e04c3fSmrgwith_ld_dynamic_list = false 145501e04c3fSmrgif cc.links('int main() { return 0; }', 145601e04c3fSmrg args : '-Wl,--dynamic-list=@0@'.format( 145701e04c3fSmrg join_paths(meson.source_root(), 'build-support/conftest.dyn')), 145801e04c3fSmrg name : 'dynamic-list') 145901e04c3fSmrg with_ld_dynamic_list = true 146001e04c3fSmrgendif 14617ec681f3Smrg 14627ec681f3Smrgld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1') 146301e04c3fSmrg 146401e04c3fSmrg# check for dl support 14657ec681f3Smrgdep_dl = null_dep 14667ec681f3Smrgif not cc.has_function('dlopen') 14677ec681f3Smrg dep_dl = cc.find_library('dl', required : host_machine.system() != 'windows') 146801e04c3fSmrgendif 146901e04c3fSmrgif cc.has_function('dladdr', dependencies : dep_dl) 147001e04c3fSmrg # This is really only required for megadrivers 147101e04c3fSmrg pre_args += '-DHAVE_DLADDR' 147201e04c3fSmrgendif 147301e04c3fSmrg 147401e04c3fSmrgif cc.has_function('dl_iterate_phdr') 147501e04c3fSmrg pre_args += '-DHAVE_DL_ITERATE_PHDR' 147601e04c3fSmrgelif with_intel_vk 147701e04c3fSmrg error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function') 147853c12917Smayaelif with_dri_i965 and with_shader_cache 147901e04c3fSmrg error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.') 148001e04c3fSmrgendif 148101e04c3fSmrg 148201e04c3fSmrg# Determine whether or not the rt library is needed for time functions 14837ec681f3Smrgif host_machine.system() == 'windows' or cc.has_function('clock_gettime') 148401e04c3fSmrg dep_clock = null_dep 148501e04c3fSmrgelse 148601e04c3fSmrg dep_clock = cc.find_library('rt') 148701e04c3fSmrgendif 148801e04c3fSmrg 14897ec681f3Smrgdep_zlib = dependency('zlib', version : '>= 1.2.3', 14907ec681f3Smrg fallback : ['zlib', 'zlib_dep'], 14917ec681f3Smrg required : get_option('zlib')) 14927ec681f3Smrgif dep_zlib.found() 14937ec681f3Smrg pre_args += '-DHAVE_ZLIB' 14947ec681f3Smrgendif 14957ec681f3Smrg 14967ec681f3Smrg_zstd = get_option('zstd') 14977ec681f3Smrgif _zstd == 'true' 14987ec681f3Smrg _zstd = 'enabled' 14997ec681f3Smrg warning('zstd option "true" deprecated, please use "enabled" instead.') 15007ec681f3Smrgelif _zstd == 'false' 15017ec681f3Smrg _zstd = 'disabled' 15027ec681f3Smrg warning('zstd option "false" deprecated, please use "disabled" instead.') 15037ec681f3Smrgendif 15047ec681f3Smrgif _zstd != 'disabled' 15057ec681f3Smrg dep_zstd = dependency('libzstd', required : _zstd == 'enabled') 15067ec681f3Smrg if dep_zstd.found() 15077ec681f3Smrg pre_args += '-DHAVE_ZSTD' 15087ec681f3Smrg endif 15097ec681f3Smrgelse 15107ec681f3Smrg dep_zstd = null_dep 15117ec681f3Smrgendif 15127ec681f3Smrg 15137ec681f3Smrgwith_compression = dep_zlib.found() or dep_zstd.found() 15147ec681f3Smrgif with_compression 15157ec681f3Smrg pre_args += '-DHAVE_COMPRESSION' 15167ec681f3Smrgelif with_shader_cache 15177ec681f3Smrg error('Shader Cache requires compression') 15187ec681f3Smrgendif 15197ec681f3Smrg 152001e04c3fSmrgdep_thread = dependency('threads') 152101e04c3fSmrgif dep_thread.found() and host_machine.system() != 'windows' 152201e04c3fSmrg pre_args += '-DHAVE_PTHREAD' 15237ec681f3Smrg if host_machine.system() != 'netbsd' and cc.has_function( 152401e04c3fSmrg 'pthread_setaffinity_np', 152501e04c3fSmrg dependencies : dep_thread, 152601e04c3fSmrg prefix : '#include <pthread.h>', 152701e04c3fSmrg args : '-D_GNU_SOURCE') 152801e04c3fSmrg pre_args += '-DHAVE_PTHREAD_SETAFFINITY' 152901e04c3fSmrg endif 153001e04c3fSmrgendif 15317ec681f3Smrgif host_machine.system() == 'darwin' 15327ec681f3Smrg dep_expat = meson.get_compiler('c').find_library('expat') 15337ec681f3Smrgelif host_machine.system() != 'windows' 15347ec681f3Smrg dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'], 15357ec681f3Smrg required: not with_platform_android) 15367ec681f3Smrgelse 15377ec681f3Smrg dep_expat = null_dep 15387ec681f3Smrgendif 153901e04c3fSmrg# this only exists on linux so either this is linux and it will be found, or 15407ec681f3Smrg# it's not linux and wont 154101e04c3fSmrgdep_m = cc.find_library('m', required : false) 154201e04c3fSmrg 15437ec681f3Smrgif host_machine.system() == 'windows' 15447ec681f3Smrg dep_regex = meson.get_compiler('c').find_library('regex', required : false) 15457ec681f3Smrg if not dep_regex.found() 15467ec681f3Smrg dep_regex = declare_dependency(compile_args : ['-DNO_REGEX']) 15477ec681f3Smrg endif 15487ec681f3Smrgelse 15497ec681f3Smrg dep_regex = null_dep 15507ec681f3Smrgendif 15517ec681f3Smrg 15527ec681f3Smrgif with_platform_haiku 15537ec681f3Smrg dep_network = cc.find_library('network') 15547ec681f3Smrgendif 15557ec681f3Smrg 15567ec681f3Smrg# Check for libdrm. Various drivers have different libdrm version requirements, 155701e04c3fSmrg# but we always want to use the same version for all libdrm modules. That means 155801e04c3fSmrg# even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and 155901e04c3fSmrg# bar are both on use 2.4.3 for both of them 156001e04c3fSmrgdep_libdrm_amdgpu = null_dep 156101e04c3fSmrgdep_libdrm_radeon = null_dep 156201e04c3fSmrgdep_libdrm_nouveau = null_dep 156301e04c3fSmrgdep_libdrm_intel = null_dep 156401e04c3fSmrg 15657ec681f3Smrg_drm_amdgpu_ver = '2.4.107' 156601e04c3fSmrg_drm_radeon_ver = '2.4.71' 15677ec681f3Smrg_drm_nouveau_ver = '2.4.102' 156801e04c3fSmrg_drm_intel_ver = '2.4.75' 156953c12917Smaya_drm_ver = '2.4.81' 157001e04c3fSmrg 157101e04c3fSmrg_libdrm_checks = [ 157201e04c3fSmrg ['intel', with_dri_i915 or with_gallium_i915], 15737ec681f3Smrg ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi], 157401e04c3fSmrg ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or 157501e04c3fSmrg with_gallium_r300 or with_gallium_r600)], 157601e04c3fSmrg ['nouveau', (with_gallium_nouveau or with_dri_nouveau)], 157701e04c3fSmrg] 157801e04c3fSmrg 157901e04c3fSmrg# VC4 only needs core libdrm support of this version, not a libdrm_vc4 158001e04c3fSmrg# library. 158101e04c3fSmrgif with_gallium_vc4 158201e04c3fSmrg _drm_ver = '2.4.89' 158301e04c3fSmrgendif 158401e04c3fSmrg 15857ec681f3Smrg# etnaviv only needs core libdrm 15867ec681f3Smrgif with_gallium_etnaviv 15877ec681f3Smrg _drm_ver = '2.4.89' 15887ec681f3Smrgendif 15897ec681f3Smrg 159001e04c3fSmrg# Loop over the enables versions and get the highest libdrm requirement for all 159101e04c3fSmrg# active drivers. 159201e04c3fSmrg_drm_blame = '' 159301e04c3fSmrgforeach d : _libdrm_checks 159401e04c3fSmrg ver = get_variable('_drm_@0@_ver'.format(d[0])) 159501e04c3fSmrg if d[1] and ver.version_compare('>' + _drm_ver) 159601e04c3fSmrg _drm_ver = ver 159701e04c3fSmrg _drm_blame = d[0] 159801e04c3fSmrg endif 159901e04c3fSmrgendforeach 160001e04c3fSmrgif _drm_blame != '' 160101e04c3fSmrg message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame)) 160201e04c3fSmrgendif 160301e04c3fSmrg 160401e04c3fSmrg# Then get each libdrm module 160501e04c3fSmrgforeach d : _libdrm_checks 160601e04c3fSmrg if d[1] 160701e04c3fSmrg set_variable( 160801e04c3fSmrg 'dep_libdrm_' + d[0], 160901e04c3fSmrg dependency('libdrm_' + d[0], version : '>=' + _drm_ver) 161001e04c3fSmrg ) 161101e04c3fSmrg endif 161201e04c3fSmrgendforeach 161301e04c3fSmrg 161401e04c3fSmrgwith_gallium_drisw_kms = false 161501e04c3fSmrgdep_libdrm = dependency( 161601e04c3fSmrg 'libdrm', version : '>=' + _drm_ver, 16177ec681f3Smrg # GNU/Hurd includes egl_dri2, without drm. 16187ec681f3Smrg required : (with_dri2 and host_machine.system() != 'gnu') or with_dri3 161901e04c3fSmrg) 162001e04c3fSmrgif dep_libdrm.found() 162101e04c3fSmrg pre_args += '-DHAVE_LIBDRM' 162201e04c3fSmrg if with_dri_platform == 'drm' and with_dri 162301e04c3fSmrg with_gallium_drisw_kms = true 162401e04c3fSmrg endif 162501e04c3fSmrgendif 162601e04c3fSmrg 16277ec681f3Smrgllvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit', 'core', 'executionengine', 'scalaropts', 'transformutils', 'instcombine'] 16287ec681f3Smrgllvm_optional_modules = ['coroutines'] 162901e04c3fSmrgif with_amd_vk or with_gallium_radeonsi or with_gallium_r600 163001e04c3fSmrg llvm_modules += ['amdgpu', 'native', 'bitreader', 'ipo'] 163101e04c3fSmrg if with_gallium_r600 163201e04c3fSmrg llvm_modules += 'asmparser' 163301e04c3fSmrg endif 163401e04c3fSmrgendif 163501e04c3fSmrgif with_gallium_opencl 163601e04c3fSmrg llvm_modules += [ 16377ec681f3Smrg 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader', 16387ec681f3Smrg 'lto', 'option', 'objcarcopts', 'profiledata' 163901e04c3fSmrg ] 16407ec681f3Smrg llvm_optional_modules += ['frontendopenmp'] 16417ec681f3Smrgendif 16427ec681f3Smrgif with_clc 16437ec681f3Smrg llvm_modules += ['coverage', 'target', 'linker', 'irreader', 'option', 'libdriver', 'lto'] 16447ec681f3Smrgendif 16457ec681f3Smrgif with_tests or with_gallium_softpipe 16467ec681f3Smrg llvm_modules += 'native' 164701e04c3fSmrgendif 164801e04c3fSmrg 164901e04c3fSmrgif with_amd_vk or with_gallium_radeonsi 16507ec681f3Smrg _llvm_version = '>= 11.0.0' 16517ec681f3Smrgelif with_clc 16527ec681f3Smrg _llvm_version = '>= 10.0.0' 16537ec681f3Smrgelif with_gallium_opencl 16547ec681f3Smrg _llvm_version = '>= 8.0.0' 165501e04c3fSmrgelif with_gallium_swr 165601e04c3fSmrg _llvm_version = '>= 6.0.0' 165701e04c3fSmrgelse 16587ec681f3Smrg _llvm_version = '>= 3.9.0' 165901e04c3fSmrgendif 166001e04c3fSmrg 166101e04c3fSmrg_shared_llvm = get_option('shared-llvm') 16627ec681f3Smrgif _shared_llvm == 'true' 16637ec681f3Smrg _shared_llvm = 'enabled' 16647ec681f3Smrg warning('shared_llvm option "true" deprecated, please use "enabled" instead.') 16657ec681f3Smrgelif _shared_llvm == 'false' 16667ec681f3Smrg _shared_llvm = 'disabled' 16677ec681f3Smrg warning('shared_llvm option "false" deprecated, please use "disabled" instead.') 16687ec681f3Smrgendif 16697ec681f3Smrgif _shared_llvm == 'auto' 16707ec681f3Smrg _shared_llvm = (host_machine.system() != 'windows') 16717ec681f3Smrgelse 16727ec681f3Smrg _shared_llvm = (_shared_llvm == 'enabled') 16737ec681f3Smrgendif 167401e04c3fSmrg_llvm = get_option('llvm') 16757ec681f3Smrgif _llvm == 'true' 16767ec681f3Smrg _llvm = 'enabled' 16777ec681f3Smrg warning('llvm option "true" deprecated, please use "enabled" instead.') 16787ec681f3Smrgelif _llvm == 'false' 16797ec681f3Smrg _llvm = 'disabled' 16807ec681f3Smrg warning('llvm option "false" deprecated, please use "disabled" instead.') 16817ec681f3Smrgendif 16827ec681f3Smrg 16837ec681f3Smrg# the cmake method can only link statically, so don't attempt to use it if we 16847ec681f3Smrg# want to link dynamically. Before 0.54.0 meson will try cmake even when shared 16857ec681f3Smrg# linking is requested, so we need to force the config-tool method to be used 16867ec681f3Smrg# in that case, but in 0.54.0 meson won't try the cmake method if shared 16877ec681f3Smrg# linking is requested. 16887ec681f3Smrg_llvm_method = 'auto' 16897ec681f3Smrgif meson.version().version_compare('< 0.54.0') and _shared_llvm 16907ec681f3Smrg _llvm_method = 'config-tool' 16917ec681f3Smrgendif 16927ec681f3Smrg 169301e04c3fSmrgdep_llvm = null_dep 169401e04c3fSmrgwith_llvm = false 16957ec681f3Smrgdraw_with_llvm = get_option('draw-use-llvm') 16967ec681f3Smrgif _llvm != 'disabled' 169701e04c3fSmrg dep_llvm = dependency( 169801e04c3fSmrg 'llvm', 169901e04c3fSmrg version : _llvm_version, 170001e04c3fSmrg modules : llvm_modules, 170101e04c3fSmrg optional_modules : llvm_optional_modules, 170201e04c3fSmrg required : ( 170301e04c3fSmrg with_amd_vk or with_gallium_radeonsi or with_gallium_swr or 17047ec681f3Smrg with_gallium_opencl or with_clc or _llvm == 'enabled' 170501e04c3fSmrg ), 170601e04c3fSmrg static : not _shared_llvm, 17077ec681f3Smrg method : _llvm_method, 17087ec681f3Smrg fallback : ['llvm', 'dep_llvm'], 17097ec681f3Smrg include_type : 'system', 171001e04c3fSmrg ) 171101e04c3fSmrg with_llvm = dep_llvm.found() 171201e04c3fSmrgendif 171301e04c3fSmrgif with_llvm 17147ec681f3Smrg pre_args += '-DLLVM_AVAILABLE' 17157ec681f3Smrg pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version()) 17167ec681f3Smrg pre_args += '-DLLVM_IS_SHARED=@0@'.format(_shared_llvm.to_int()) 17177ec681f3Smrg 17187ec681f3Smrg if draw_with_llvm 17197ec681f3Smrg pre_args += '-DDRAW_LLVM_AVAILABLE' 17207ec681f3Smrg elif with_swrast_vk 17217ec681f3Smrg error('Lavapipe requires LLVM draw support.') 17227ec681f3Smrg elif with_gallium_swr 17237ec681f3Smrg error('SWR requires LLVM draw support.') 17247ec681f3Smrg endif 172501e04c3fSmrg 172601e04c3fSmrg # LLVM can be built without rtti, turning off rtti changes the ABI of C++ 172701e04c3fSmrg # programs, so we need to build all C++ code in mesa without rtti as well to 172801e04c3fSmrg # ensure that linking works. 17297ec681f3Smrg # 17307ec681f3Smrg # In meson 0.51.0 we can use cmake to find LLVM in addittion to meson's 17317ec681f3Smrg # builtin llvm-config based finder. A new generic variable getter method 17327ec681f3Smrg # has also been added, so we'll use that if we can, to cover the cmake case. 17337ec681f3Smrg if dep_llvm.type_name() == 'internal' 17347ec681f3Smrg _rtti = subproject('llvm').get_variable('has_rtti', true) 17357ec681f3Smrg else 17367ec681f3Smrg # The CMake finder will return 'ON', the llvm-config will return 'YES' 17377ec681f3Smrg _rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti')) 17387ec681f3Smrg endif 17397ec681f3Smrg if not _rtti 17407ec681f3Smrg if with_gallium_opencl 174153c12917Smaya error('The Clover OpenCL state tracker requires rtti, you need to turn off clover or use an LLVM built with LLVM_ENABLE_RTTI.') 174201e04c3fSmrg endif 17437ec681f3Smrg if cc.get_id() == 'msvc' 17447ec681f3Smrg cpp_args += '/GR-' 17457ec681f3Smrg else 17467ec681f3Smrg cpp_args += '-fno-rtti' 17477ec681f3Smrg endif 17487ec681f3Smrg endif 17497ec681f3Smrg 17507ec681f3Smrg if cc.get_id() == 'msvc' 17517ec681f3Smrg # Suppress "/DELAYLOAD:ole32.dll/shell32.dll ignored" warnings that LLVM adds 17527ec681f3Smrg add_project_link_arguments( 17537ec681f3Smrg '/ignore:4199', 17547ec681f3Smrg language : ['c', 'cpp'], 17557ec681f3Smrg ) 175601e04c3fSmrg endif 17577ec681f3Smrgelif with_amd_vk and with_aco_tests 17587ec681f3Smrg error('ACO tests require LLVM, but LLVM is disabled.') 17597ec681f3Smrgelif with_gallium_radeonsi or with_gallium_swr or with_swrast_vk 17607ec681f3Smrg error('The following drivers require LLVM: RadeonSI, SWR, Lavapipe. One of these is enabled, but LLVM is disabled.') 176153c12917Smayaelif with_gallium_opencl 176253c12917Smaya error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.') 17637ec681f3Smrgelif with_clc 17647ec681f3Smrg error('The CLC compiler requires LLVM, but LLVM is disabled.') 17657ec681f3Smrgelse 17667ec681f3Smrg draw_with_llvm = false 17677ec681f3Smrgendif 17687ec681f3Smrg 17697ec681f3Smrgwith_opencl_spirv = (_opencl != 'disabled' and get_option('opencl-spirv')) or with_clc 17707ec681f3Smrgif with_opencl_spirv 17717ec681f3Smrg chosen_llvm_version_array = dep_llvm.version().split('.') 17727ec681f3Smrg chosen_llvm_version_major = chosen_llvm_version_array[0].to_int() 17737ec681f3Smrg chosen_llvm_version_minor = chosen_llvm_version_array[1].to_int() 17747ec681f3Smrg 17757ec681f3Smrg # Require an SPIRV-LLVM-Translator version compatible with the chosen LLVM 17767ec681f3Smrg # one. 17777ec681f3Smrg _llvmspirvlib_version = [ 17787ec681f3Smrg # This first version check is still needed as maybe LLVM 8.0 was picked but 17797ec681f3Smrg # we do not want to accept SPIRV-LLVM-Translator 8.0.0.1 as that version does 17807ec681f3Smrg # not have the required API and those are only available starting from 17817ec681f3Smrg # 8.0.1.3. 17827ec681f3Smrg '>= 8.0.1.3', 17837ec681f3Smrg '>= @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor), 17847ec681f3Smrg '< @0@.@1@'.format(chosen_llvm_version_major, chosen_llvm_version_minor + 1) ] 17857ec681f3Smrg 17867ec681f3Smrg dep_spirv_tools = dependency('SPIRV-Tools', required : true, version : '>= 2018.0') 17877ec681f3Smrg # LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator 17887ec681f3Smrg dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : _llvmspirvlib_version) 17897ec681f3Smrgelse 17907ec681f3Smrg dep_spirv_tools = null_dep 17917ec681f3Smrg dep_llvmspirvlib = null_dep 179201e04c3fSmrgendif 179301e04c3fSmrg 17947ec681f3Smrgdep_clang = null_dep 17957ec681f3Smrgif with_clc 17967ec681f3Smrg llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir') 17977ec681f3Smrg 17987ec681f3Smrg clang_modules = [ 17997ec681f3Smrg 'clangBasic', 'clangAST', 'clangCodeGen', 'clangLex', 18007ec681f3Smrg 'clangDriver', 'clangFrontend', 'clangFrontendTool', 18017ec681f3Smrg 'clangHandleCXX', 'clangHandleLLVM', 'clangSerialization', 18027ec681f3Smrg 'clangSema', 'clangParse', 'clangEdit', 'clangAnalysis' 18037ec681f3Smrg ] 18047ec681f3Smrg 18057ec681f3Smrg dep_clang = [] 18067ec681f3Smrg foreach m : clang_modules 18077ec681f3Smrg dep_clang += cpp.find_library(m, dirs : llvm_libdir, required : true) 18087ec681f3Smrg endforeach 18097ec681f3Smrgendif 18107ec681f3Smrg 18117ec681f3Smrg# Be explicit about only using this lib on Windows, to avoid picking 18127ec681f3Smrg# up random libs with the generic name 'libversion' 18137ec681f3Smrgdep_version = null_dep 18147ec681f3Smrgif with_opencl_spirv and host_machine.system() == 'windows' 18157ec681f3Smrg dep_version = cpp.find_library('version') 18167ec681f3Smrgendif 18177ec681f3Smrg 18187ec681f3Smrgwith_opencl_native = _opencl != 'disabled' and get_option('opencl-native') 18197ec681f3Smrg 18207ec681f3Smrgif (with_amd_vk or with_gallium_radeonsi or 18217ec681f3Smrg (with_gallium_opencl and with_opencl_native) or 182201e04c3fSmrg (with_gallium_r600 and with_llvm)) 18237ec681f3Smrg if with_platform_windows 18247ec681f3Smrg dep_elf = dependency('libelf', required : false, fallback : ['libelf', 'libelf_dep']) 18257ec681f3Smrg else 18267ec681f3Smrg dep_elf = dependency('libelf', required : false) 18277ec681f3Smrg endif 182801e04c3fSmrg if not dep_elf.found() 182901e04c3fSmrg dep_elf = cc.find_library('elf') 183001e04c3fSmrg endif 183101e04c3fSmrgelse 183201e04c3fSmrg dep_elf = null_dep 183301e04c3fSmrgendif 183401e04c3fSmrg 183501e04c3fSmrgdep_glvnd = null_dep 183601e04c3fSmrgif with_glvnd 18377ec681f3Smrg dep_glvnd = dependency('libglvnd', version : '>= 1.3.2') 183801e04c3fSmrg pre_args += '-DUSE_LIBGLVND=1' 183901e04c3fSmrgendif 184001e04c3fSmrg 18417ec681f3Smrg_valgrind = get_option('valgrind') 18427ec681f3Smrgif _valgrind == 'true' 18437ec681f3Smrg _valgrind = 'enabled' 18447ec681f3Smrg warning('valgrind option "true" deprecated, please use "enabled" instead.') 18457ec681f3Smrgelif _valgrind == 'false' 18467ec681f3Smrg _valgrind = 'disabled' 18477ec681f3Smrg warning('valgrind option "false" deprecated, please use "disabled" instead.') 18487ec681f3Smrgendif 18497ec681f3Smrgif _valgrind != 'disabled' 18507ec681f3Smrg dep_valgrind = dependency('valgrind', required : _valgrind == 'enabled') 185101e04c3fSmrg if dep_valgrind.found() 185201e04c3fSmrg pre_args += '-DHAVE_VALGRIND' 185301e04c3fSmrg endif 185401e04c3fSmrgelse 185501e04c3fSmrg dep_valgrind = null_dep 185601e04c3fSmrgendif 185701e04c3fSmrg 18587ec681f3Smrg# AddressSanitizer's leak reports need all the symbols to be present at exit to 18597ec681f3Smrg# decode well, which runs afoul of our dlopen()/dlclose()ing of the DRI drivers. 18607ec681f3Smrg# Set a flag so we can skip the dlclose for asan builds. 18617ec681f3Smrgif ['address', 'address,undefined'].contains(get_option('b_sanitize')) 18627ec681f3Smrg asan_c_args = ['-DBUILT_WITH_ASAN=1'] 18637ec681f3Smrgelse 18647ec681f3Smrg asan_c_args = ['-DBUILT_WITH_ASAN=0'] 18657ec681f3Smrgendif 18667ec681f3Smrg 18677ec681f3Smrgyacc_is_bison = true 18687ec681f3Smrg 18697ec681f3Smrgif build_machine.system() == 'windows' 18707ec681f3Smrg # Prefer the winflexbison versions, they're much easier to install and have 18717ec681f3Smrg # better windows support. 18727ec681f3Smrg 18737ec681f3Smrg prog_flex = find_program('win_flex', required : false) 18747ec681f3Smrg if prog_flex.found() 18757ec681f3Smrg # windows compatibility (uses <io.h> instead of <unistd.h> and _isatty, 18767ec681f3Smrg # _fileno functions) 18777ec681f3Smrg prog_flex = [prog_flex, '--wincompat'] 18787ec681f3Smrg if get_option('c_std') == 'c99' 18797ec681f3Smrg prog_flex += '-D__STDC_VERSION__=199901' 18807ec681f3Smrg endif 18817ec681f3Smrg else 18827ec681f3Smrg prog_flex = [find_program('flex', 'lex', required : with_any_opengl)] 18837ec681f3Smrg endif 18847ec681f3Smrg # Force flex to use const keyword in prototypes, as relies on __cplusplus or 18857ec681f3Smrg # __STDC__ macro to determine whether it's safe to use const keyword, but 18867ec681f3Smrg # MSVC only defines __STDC_VERSION__ for C11/C17. 18877ec681f3Smrg prog_flex += '-DYY_USE_CONST=' 18887ec681f3Smrg 18897ec681f3Smrg prog_flex_cpp = prog_flex 18907ec681f3Smrg if get_option('c_std') != 'c99' 18917ec681f3Smrg # Convince win_flex to use <inttypes.h> for C++ files 18927ec681f3Smrg prog_flex_cpp += '-D__STDC_VERSION__=199901' 18937ec681f3Smrg endif 18947ec681f3Smrg 18957ec681f3Smrg prog_bison = find_program('win_bison', required : false) 18967ec681f3Smrg if not prog_bison.found() 18977ec681f3Smrg prog_bison = find_program('bison', 'yacc', required : with_any_opengl) 18987ec681f3Smrg endif 18997ec681f3Smrgelse 19007ec681f3Smrg prog_bison = find_program('bison', required : false) 190101e04c3fSmrg 19027ec681f3Smrg if not prog_bison.found() 19037ec681f3Smrg prog_bison = find_program('byacc', required : with_any_opengl) 19047ec681f3Smrg yacc_is_bison = false 19057ec681f3Smrg endif 19067ec681f3Smrg 19077ec681f3Smrg # Disable deprecated keyword warnings, since we have to use them for 19087ec681f3Smrg # old-bison compat. See discussion in 19097ec681f3Smrg # https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2161 19107ec681f3Smrg if find_program('bison', required : false, version : '> 2.3').found() 19117ec681f3Smrg prog_bison = [prog_bison, '-Wno-deprecated'] 19127ec681f3Smrg endif 19137ec681f3Smrg 19147ec681f3Smrg prog_flex = find_program('flex', required : with_any_opengl) 19157ec681f3Smrg prog_flex_cpp = prog_flex 19167ec681f3Smrgendif 191701e04c3fSmrg 191801e04c3fSmrgdep_selinux = null_dep 191901e04c3fSmrgif get_option('selinux') 19207ec681f3Smrg if get_option('execmem') != true 19217ec681f3Smrg warning('execmem option is disabled, selinux will not be able to use execmem.') 19227ec681f3Smrg endif 192301e04c3fSmrg dep_selinux = dependency('libselinux') 192401e04c3fSmrg pre_args += '-DMESA_SELINUX' 192501e04c3fSmrgendif 192601e04c3fSmrg 19277ec681f3Smrgif get_option('execmem') 19287ec681f3Smrg pre_args += '-DMESA_EXECMEM' 19297ec681f3Smrgendif 19307ec681f3Smrg 19317ec681f3Smrg_libunwind = get_option('libunwind') 19327ec681f3Smrgif _libunwind == 'true' 19337ec681f3Smrg _libunwind = 'enabled' 19347ec681f3Smrg warning('libunwind option "true" deprecated, please use "enabled" instead.') 19357ec681f3Smrgelif _libunwind == 'false' 19367ec681f3Smrg _libunwind = 'disabled' 19377ec681f3Smrg warning('libunwind option "false" deprecated, please use "disabled" instead.') 19387ec681f3Smrgendif 19397ec681f3Smrgif _libunwind != 'disabled' and not with_platform_android 19407ec681f3Smrg if host_machine.system() == 'darwin' 19417ec681f3Smrg dep_unwind = meson.get_compiler('c').find_library('System') 19427ec681f3Smrg else 19437ec681f3Smrg dep_unwind = dependency('libunwind', required : _libunwind == 'enabled') 19447ec681f3Smrg endif 194501e04c3fSmrg if dep_unwind.found() 194601e04c3fSmrg pre_args += '-DHAVE_LIBUNWIND' 194701e04c3fSmrg endif 194801e04c3fSmrgelse 194901e04c3fSmrg dep_unwind = null_dep 195001e04c3fSmrgendif 195101e04c3fSmrg 19527ec681f3Smrgif with_osmesa 19537ec681f3Smrg if not with_gallium_softpipe 195401e04c3fSmrg error('OSMesa gallium requires gallium softpipe or llvmpipe.') 195501e04c3fSmrg endif 19567ec681f3Smrg if host_machine.system() == 'windows' 19577ec681f3Smrg osmesa_lib_name = 'osmesa' 19587ec681f3Smrg else 19597ec681f3Smrg osmesa_lib_name = 'OSMesa' 19607ec681f3Smrg endif 196101e04c3fSmrg osmesa_bits = get_option('osmesa-bits') 196201e04c3fSmrg if osmesa_bits != '8' 196301e04c3fSmrg if with_dri or with_glx != 'disabled' 19647ec681f3Smrg error('OSMesa bits must be 8 if building glx or dri based drivers') 196501e04c3fSmrg endif 196601e04c3fSmrg osmesa_lib_name = osmesa_lib_name + osmesa_bits 196701e04c3fSmrg pre_args += [ 196801e04c3fSmrg '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31' 196901e04c3fSmrg ] 197001e04c3fSmrg endif 197101e04c3fSmrgendif 197201e04c3fSmrg 197301e04c3fSmrg# TODO: symbol mangling 197401e04c3fSmrg 197501e04c3fSmrgif with_platform_wayland 197601e04c3fSmrg dep_wl_scanner = dependency('wayland-scanner', native: true) 197701e04c3fSmrg prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner')) 197801e04c3fSmrg if dep_wl_scanner.version().version_compare('>= 1.15') 197901e04c3fSmrg wl_scanner_arg = 'private-code' 198001e04c3fSmrg else 198101e04c3fSmrg wl_scanner_arg = 'code' 198201e04c3fSmrg endif 198301e04c3fSmrg dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8') 19847ec681f3Smrg dep_wayland_client = dependency('wayland-client', version : '>=1.18') 19857ec681f3Smrg dep_wayland_server = dependency('wayland-server', version : '>=1.18') 198601e04c3fSmrg if with_egl 198701e04c3fSmrg dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3') 19887ec681f3Smrg dep_wayland_egl_headers = dep_wayland_egl.partial_dependency(compile_args : true) 198901e04c3fSmrg endif 199001e04c3fSmrg wayland_dmabuf_xml = join_paths( 199101e04c3fSmrg dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable', 199201e04c3fSmrg 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml' 199301e04c3fSmrg ) 199401e04c3fSmrg pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED'] 199501e04c3fSmrgendif 199601e04c3fSmrg 199701e04c3fSmrgdep_x11 = null_dep 199801e04c3fSmrgdep_xext = null_dep 199901e04c3fSmrgdep_xfixes = null_dep 200001e04c3fSmrgdep_x11_xcb = null_dep 200101e04c3fSmrgdep_xcb = null_dep 200201e04c3fSmrgdep_xcb_glx = null_dep 200301e04c3fSmrgdep_xcb_dri2 = null_dep 200401e04c3fSmrgdep_xcb_dri3 = null_dep 200501e04c3fSmrgdep_dri2proto = null_dep 200601e04c3fSmrgdep_glproto = null_dep 200701e04c3fSmrgdep_xxf86vm = null_dep 200801e04c3fSmrgdep_xcb_dri3 = null_dep 200901e04c3fSmrgdep_xcb_present = null_dep 201001e04c3fSmrgdep_xcb_sync = null_dep 201101e04c3fSmrgdep_xcb_xfixes = null_dep 201201e04c3fSmrgdep_xshmfence = null_dep 201301e04c3fSmrgdep_xcb_xrandr = null_dep 20147ec681f3Smrgdep_xcb_shm = null_dep 201501e04c3fSmrgdep_xlib_xrandr = null_dep 20167ec681f3Smrgdep_openmp = null_dep 20177ec681f3Smrg 20187ec681f3Smrg# Even if we find OpenMP, Gitlab CI fails to link with gcc/i386 and clang/anyarch. 20197ec681f3Smrgif host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc' 20207ec681f3Smrg dep_openmp = dependency('openmp', required : false) 20217ec681f3Smrg if dep_openmp.found() 20227ec681f3Smrg pre_args += ['-DHAVE_OPENMP'] 20237ec681f3Smrg endif 20247ec681f3Smrgendif 20257ec681f3Smrg 202601e04c3fSmrgif with_platform_x11 202701e04c3fSmrg if with_glx == 'xlib' or with_glx == 'gallium-xlib' 202801e04c3fSmrg dep_x11 = dependency('x11') 202901e04c3fSmrg dep_xext = dependency('xext') 203001e04c3fSmrg dep_xcb = dependency('xcb') 203101e04c3fSmrg elif with_glx == 'dri' 203201e04c3fSmrg dep_x11 = dependency('x11') 203301e04c3fSmrg dep_xext = dependency('xext') 20347ec681f3Smrg dep_xfixes = dependency('xfixes', version : '>= 2.0') 203501e04c3fSmrg dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1') 20367ec681f3Smrg dep_xcb_shm = dependency('xcb-shm') 203701e04c3fSmrg endif 203853c12917Smaya if (with_any_vk or with_glx == 'dri' or with_egl or 203901e04c3fSmrg (with_gallium_vdpau or with_gallium_xvmc or with_gallium_va or 204001e04c3fSmrg with_gallium_omx != 'disabled')) 204101e04c3fSmrg dep_xcb = dependency('xcb') 204201e04c3fSmrg dep_x11_xcb = dependency('x11-xcb') 20437ec681f3Smrg if with_dri_platform == 'drm' and not dep_libdrm.found() 20447ec681f3Smrg error('libdrm required for gallium video statetrackers when using x11') 20457ec681f3Smrg endif 204601e04c3fSmrg endif 204701e04c3fSmrg if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm') 204801e04c3fSmrg dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8') 204901e04c3fSmrg 205001e04c3fSmrg if with_dri3 205101e04c3fSmrg pre_args += '-DHAVE_DRI3' 205201e04c3fSmrg dep_xcb_dri3 = dependency('xcb-dri3') 205301e04c3fSmrg dep_xcb_present = dependency('xcb-present') 205401e04c3fSmrg # until xcb-dri3 has been around long enough to make a hard-dependency: 205501e04c3fSmrg if (dep_xcb_dri3.version().version_compare('>= 1.13') and 205601e04c3fSmrg dep_xcb_present.version().version_compare('>= 1.13')) 205701e04c3fSmrg pre_args += '-DHAVE_DRI3_MODIFIERS' 205801e04c3fSmrg endif 20597ec681f3Smrg dep_xcb_shm = dependency('xcb-shm') 206001e04c3fSmrg dep_xcb_sync = dependency('xcb-sync') 206101e04c3fSmrg dep_xshmfence = dependency('xshmfence', version : '>= 1.1') 206201e04c3fSmrg endif 206301e04c3fSmrg endif 206453c12917Smaya if with_glx == 'dri' or with_glx == 'gallium-xlib' 206553c12917Smaya dep_glproto = dependency('glproto', version : '>= 1.4.14') 206653c12917Smaya endif 20677ec681f3Smrg if with_glx == 'dri' 206801e04c3fSmrg if with_dri_platform == 'drm' 206901e04c3fSmrg dep_dri2proto = dependency('dri2proto', version : '>= 2.8') 20707ec681f3Smrg if with_glx_direct 20717ec681f3Smrg dep_xxf86vm = dependency('xxf86vm') 20727ec681f3Smrg endif 207301e04c3fSmrg endif 207401e04c3fSmrg endif 20757ec681f3Smrg if (with_egl or 20767ec681f3Smrg with_dri3 or ( 207701e04c3fSmrg with_gallium_vdpau or with_gallium_xvmc or with_gallium_xa or 207801e04c3fSmrg with_gallium_omx != 'disabled')) 207901e04c3fSmrg dep_xcb_xfixes = dependency('xcb-xfixes') 208001e04c3fSmrg endif 20817ec681f3Smrg if with_xlib_lease or with_any_vk 208201e04c3fSmrg dep_xcb_xrandr = dependency('xcb-randr') 20837ec681f3Smrg endif 20847ec681f3Smrg if with_xlib_lease 208501e04c3fSmrg dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3') 208601e04c3fSmrg endif 208701e04c3fSmrgendif 208801e04c3fSmrg 208901e04c3fSmrgif get_option('gallium-extra-hud') 209001e04c3fSmrg pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1' 209101e04c3fSmrgendif 209201e04c3fSmrg 209301e04c3fSmrg_sensors = get_option('lmsensors') 20947ec681f3Smrgif _sensors == 'true' 20957ec681f3Smrg _sensors = 'enabled' 20967ec681f3Smrg warning('lmsensors option "true" deprecated, please use "enabled" instead.') 20977ec681f3Smrgelif _sensors == 'false' 20987ec681f3Smrg _sensors = 'disabled' 20997ec681f3Smrg warning('lmsensors option "false" deprecated, please use "disabled" instead.') 21007ec681f3Smrgendif 21017ec681f3Smrgif _sensors != 'disabled' 21027ec681f3Smrg dep_lmsensors = cc.find_library('sensors', required : _sensors == 'enabled') 210301e04c3fSmrg if dep_lmsensors.found() 210401e04c3fSmrg pre_args += '-DHAVE_LIBSENSORS=1' 210501e04c3fSmrg endif 210601e04c3fSmrgelse 210701e04c3fSmrg dep_lmsensors = null_dep 210801e04c3fSmrgendif 210901e04c3fSmrg 21107ec681f3Smrg_shader_replacement = get_option('custom-shader-replacement') 21117ec681f3Smrgif _shader_replacement == '' 21127ec681f3Smrgelse 21137ec681f3Smrg pre_args += '-DCUSTOM_SHADER_REPLACEMENT' 21147ec681f3Smrgendif 21157ec681f3Smrg 21167ec681f3Smrgwith_perfetto = get_option('perfetto') 21177ec681f3Smrgwith_datasources = get_option('datasources') 21187ec681f3Smrgwith_any_datasource = with_datasources.length() != 0 21197ec681f3Smrgif with_perfetto 21207ec681f3Smrg dep_perfetto = dependency('perfetto', fallback: ['perfetto', 'dep_perfetto']) 21217ec681f3Smrg pre_args += '-DHAVE_PERFETTO' 21227ec681f3Smrgendif 21237ec681f3Smrg 21247ec681f3Smrg# If the compiler supports it, put function and data symbols in their 21257ec681f3Smrg# own sections and GC the sections after linking. This lets drivers 21267ec681f3Smrg# drop shared code unused by that specific driver (particularly 21277ec681f3Smrg# relevant for Vulkan drivers). 21287ec681f3Smrgif cc.has_link_argument('-Wl,--gc-sections') 21297ec681f3Smrg foreach a: ['-ffunction-sections', '-fdata-sections'] 21307ec681f3Smrg if cc.has_argument(a) 21317ec681f3Smrg add_project_arguments(a, language : ['c', 'cpp']) 21327ec681f3Smrg endif 21337ec681f3Smrg endforeach 21347ec681f3Smrgendif 21357ec681f3Smrg 213601e04c3fSmrgforeach a : pre_args 213701e04c3fSmrg add_project_arguments(a, language : ['c', 'cpp']) 213801e04c3fSmrgendforeach 213901e04c3fSmrgforeach a : c_args 214001e04c3fSmrg add_project_arguments(a, language : ['c']) 214101e04c3fSmrgendforeach 214201e04c3fSmrgforeach a : cpp_args 214301e04c3fSmrg add_project_arguments(a, language : ['cpp']) 214401e04c3fSmrgendforeach 214501e04c3fSmrg 214601e04c3fSmrggl_priv_reqs = [] 214701e04c3fSmrg 214801e04c3fSmrgif with_glx == 'xlib' or with_glx == 'gallium-xlib' 214901e04c3fSmrg gl_priv_reqs += ['x11', 'xext', 'xcb'] 215001e04c3fSmrgelif with_glx == 'dri' 215101e04c3fSmrg gl_priv_reqs += [ 21527ec681f3Smrg 'x11', 'xext', 'xfixes', 'x11-xcb', 'xcb', 215301e04c3fSmrg 'xcb-glx >= 1.8.1'] 215401e04c3fSmrg if with_dri_platform == 'drm' 215501e04c3fSmrg gl_priv_reqs += 'xcb-dri2 >= 1.8' 21567ec681f3Smrg if with_glx_direct 21577ec681f3Smrg gl_priv_reqs += 'xxf86vm' 21587ec681f3Smrg endif 215901e04c3fSmrg endif 216001e04c3fSmrgendif 216101e04c3fSmrgif dep_libdrm.found() 216201e04c3fSmrg gl_priv_reqs += 'libdrm >= 2.4.75' 216301e04c3fSmrgendif 216401e04c3fSmrg 216501e04c3fSmrggl_priv_libs = [] 216601e04c3fSmrgif dep_thread.found() 216701e04c3fSmrg gl_priv_libs += ['-lpthread', '-pthread'] 216801e04c3fSmrgendif 216901e04c3fSmrgif dep_m.found() 217001e04c3fSmrg gl_priv_libs += '-lm' 217101e04c3fSmrgendif 217201e04c3fSmrgif dep_dl.found() 217301e04c3fSmrg gl_priv_libs += '-ldl' 217401e04c3fSmrgendif 217501e04c3fSmrg 21767ec681f3Smrg# FIXME: autotools lists this as incomplete 21777ec681f3Smrggbm_priv_libs = [] 21787ec681f3Smrgif dep_dl.found() 21797ec681f3Smrg gbm_priv_libs += '-ldl' 21807ec681f3Smrgendif 21817ec681f3Smrg 218201e04c3fSmrgpkg = import('pkgconfig') 218301e04c3fSmrg 21847ec681f3Smrgif host_machine.system() == 'windows' 21857ec681f3Smrg prog_dumpbin = find_program('dumpbin', required : false) 21867ec681f3Smrg with_symbols_check = prog_dumpbin.found() and with_tests 21877ec681f3Smrg if with_symbols_check 21887ec681f3Smrg symbols_check_args = ['--dumpbin', prog_dumpbin.path()] 21897ec681f3Smrg endif 21907ec681f3Smrgelse 21917ec681f3Smrg prog_nm = find_program('nm') 21927ec681f3Smrg with_symbols_check = with_tests 21937ec681f3Smrg symbols_check_args = ['--nm', prog_nm.path()] 219453c12917Smayaendif 219553c12917Smaya 219653c12917Smaya# This quirk needs to be applied to sources with functions defined in assembly 219753c12917Smaya# as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391 219853c12917Smayagcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : [] 219901e04c3fSmrg 220001e04c3fSmrgsubdir('include') 220101e04c3fSmrgsubdir('bin') 220201e04c3fSmrgsubdir('src') 220353c12917Smaya 220453c12917Smaya# Meson 0.49 and earlier seems to have a bug that fails to evaluate the string- 220553c12917Smaya# formatting below unless the first argument is passed as a variable. This has 220653c12917Smaya# been fixed in Meson 0.50 and beyond, but we need to keep it like this for now 220753c12917Smaya# for backwards compatibility. 220853c12917Smaya_with_opengl_string = with_opengl ? 'yes' : 'no' 220953c12917Smaya 221053c12917Smayalines = ['', 221153c12917Smaya 'prefix: ' + get_option('prefix'), 221253c12917Smaya 'libdir: ' + get_option('libdir'), 221353c12917Smaya 'includedir: ' + get_option('includedir'), 221453c12917Smaya '', 221553c12917Smaya 'OpenGL: @0@ (ES1: @1@ ES2: @2@)'.format(_with_opengl_string, 221653c12917Smaya with_gles1 ? 'yes' : 'no', 221753c12917Smaya with_gles2 ? 'yes' : 'no'), 221853c12917Smaya] 221953c12917Smaya 22207ec681f3Smrgif with_osmesa 22217ec681f3Smrg lines += '' 22227ec681f3Smrg lines += 'OSMesa: lib' + osmesa_lib_name 222353c12917Smayaelse 222453c12917Smaya lines += 'OSMesa: no' 222553c12917Smayaendif 222653c12917Smaya 222753c12917Smayaif with_dri 22287ec681f3Smrg lines += '' 222953c12917Smaya lines += 'DRI platform: ' + with_dri_platform 223053c12917Smaya if dri_drivers.length() != 0 and dri_drivers != [''] 223153c12917Smaya lines += 'DRI drivers: ' + ' '.join(dri_drivers) 223253c12917Smaya else 223353c12917Smaya lines += 'DRI drivers: no' 223453c12917Smaya endif 223553c12917Smaya lines += 'DRI driver dir: ' + dri_drivers_path 223653c12917Smayaendif 223753c12917Smaya 223853c12917Smayaif with_glx != 'disabled' 22397ec681f3Smrg lines += '' 224053c12917Smaya if with_glx == 'dri' 224153c12917Smaya lines += 'GLX: DRI-based' 224253c12917Smaya elif with_glx == 'xlib' 224353c12917Smaya lines += 'GLX: Xlib-based' 224453c12917Smaya elif with_glx == 'gallium-xlib' 224553c12917Smaya lines += 'GLX: Xlib-based (Gallium)' 224653c12917Smaya else 224753c12917Smaya lines += 'GLX: ' + with_glx 224853c12917Smaya endif 224953c12917Smayaendif 225053c12917Smaya 225153c12917Smayalines += '' 225253c12917Smayalines += 'EGL: ' + (with_egl ? 'yes' : 'no') 225353c12917Smayaif with_egl 225453c12917Smaya egl_drivers = [] 225553c12917Smaya if with_dri 225653c12917Smaya egl_drivers += 'builtin:egl_dri2' 225753c12917Smaya endif 225853c12917Smaya if with_dri3 225953c12917Smaya egl_drivers += 'builtin:egl_dri3' 226053c12917Smaya endif 22617ec681f3Smrg if with_platform_windows 22627ec681f3Smrg egl_drivers += 'builtin:wgl' 22637ec681f3Smrg endif 226453c12917Smaya lines += 'EGL drivers: ' + ' '.join(egl_drivers) 226553c12917Smayaendif 22667ec681f3Smrgif with_egl or with_any_vk 226753c12917Smaya lines += 'EGL/Vulkan/VL platforms: ' + ' '.join(_platforms) 226853c12917Smayaendif 22697ec681f3Smrglines += 'GBM: ' + (with_gbm ? 'yes' : 'no') 22707ec681f3Smrgif with_gbm 22717ec681f3Smrg lines += 'GBM backends path: ' + gbm_backends_path 22727ec681f3Smrgendif 227353c12917Smaya 227453c12917Smayalines += '' 227553c12917Smayaif with_any_vk 227653c12917Smaya lines += 'Vulkan drivers: ' + ' '.join(_vulkan_drivers) 227753c12917Smaya lines += 'Vulkan ICD dir: ' + with_vulkan_icd_dir 22787ec681f3Smrg if with_any_vulkan_layers 22797ec681f3Smrg lines += 'Vulkan layers: ' + ' '.join(get_option('vulkan-layers')) 22807ec681f3Smrg endif 228153c12917Smayaelse 228253c12917Smaya lines += 'Vulkan drivers: no' 228353c12917Smayaendif 228453c12917Smaya 228553c12917Smayalines += '' 228653c12917Smayaif with_llvm 228753c12917Smaya lines += 'llvm: yes' 228853c12917Smaya lines += 'llvm-version: ' + dep_llvm.version() 228953c12917Smayaelse 229053c12917Smaya lines += 'llvm: no' 229153c12917Smayaendif 229253c12917Smaya 229353c12917Smayalines += '' 229453c12917Smayaif with_gallium 229553c12917Smaya lines += 'Gallium drivers: ' + ' '.join(gallium_drivers) 229653c12917Smaya gallium_st = ['mesa'] 229753c12917Smaya if with_gallium_xa 229853c12917Smaya gallium_st += 'xa' 229953c12917Smaya endif 230053c12917Smaya if with_gallium_xvmc 230153c12917Smaya gallium_st += 'xvmc' 230253c12917Smaya endif 230353c12917Smaya if with_gallium_vdpau 230453c12917Smaya gallium_st += 'vdpau' 230553c12917Smaya endif 230653c12917Smaya if with_gallium_omx != 'disabled' 230753c12917Smaya gallium_st += 'omx' + with_gallium_omx 230853c12917Smaya endif 230953c12917Smaya if with_gallium_va 231053c12917Smaya gallium_st += 'va' 231153c12917Smaya endif 231253c12917Smaya if with_gallium_st_nine 231353c12917Smaya gallium_st += 'nine' 231453c12917Smaya endif 231553c12917Smaya if with_gallium_opencl 231653c12917Smaya gallium_st += 'clover' 231753c12917Smaya endif 231853c12917Smaya lines += 'Gallium st: ' + ' '.join(gallium_st) 231953c12917Smayaelse 232053c12917Smaya lines += 'Gallium: no' 232153c12917Smayaendif 232253c12917Smaya 232353c12917Smayalines += 'HUD lmsensors: ' + (dep_lmsensors.found() ? 'yes' : 'no') 232453c12917Smaya 232553c12917Smayalines += '' 232653c12917Smayalines += 'Shared-glapi: ' + (with_shared_glapi ? 'yes' : 'no') 232753c12917Smaya 23287ec681f3Smrglines += '' 23297ec681f3Smrglines += 'Perfetto: ' + (with_perfetto ? 'yes' : 'no') 23307ec681f3Smrgif with_any_datasource 23317ec681f3Smrg lines += 'Perfetto ds: ' + ' '.join(with_datasources) 23327ec681f3Smrgendif 23337ec681f3Smrg 233453c12917Smaya 233553c12917Smayaindent = ' ' 233653c12917Smayasummary = indent + ('\n' + indent).join(lines) 233753c12917Smayamessage('Configuration summary:\n@0@\n'.format(summary)) 2338