Home | History | Annotate | Download | only in mesa3d
      1 # Copyright  2017 Intel Corporation
      2 
      3 # Permission is hereby granted, free of charge, to any person obtaining a copy
      4 # of this software and associated documentation files (the "Software"), to deal
      5 # in the Software without restriction, including without limitation the rights
      6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      7 # copies of the Software, and to permit persons to whom the Software is
      8 # furnished to do so, subject to the following conditions:
      9 
     10 # The above copyright notice and this permission notice shall be included in
     11 # all copies or substantial portions of the Software.
     12 
     13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     19 # SOFTWARE.
     20 
     21 project(
     22   'mesa',
     23   ['c', 'cpp'],
     24   version : run_command(
     25     [find_program('python', 'python2', 'python3'), 'bin/meson_get_version.py']
     26   ).stdout(),
     27   license : 'MIT',
     28   meson_version : '>= 0.42',
     29   default_options : ['buildtype=debugoptimized', 'c_std=c99', 'cpp_std=c++11']
     30 )
     31 
     32 # Arguments for the preprocessor, put these in a separate array from the C and
     33 # C++ (cpp in meson terminology) arguments since they need to be added to the
     34 # default arguments for both C and C++.
     35 pre_args = [
     36   '-D__STDC_CONSTANT_MACROS',
     37   '-D__STDC_FORMAT_MACROS',
     38   '-D__STDC_LIMIT_MACROS',
     39   '-DVERSION="@0@"'.format(meson.project_version()),
     40   '-DPACKAGE_VERSION=VERSION',
     41   '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"',
     42 ]
     43 
     44 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
     45 with_tests = get_option('build-tests')
     46 with_valgrind = get_option('valgrind')
     47 with_libunwind = get_option('libunwind')
     48 with_asm = get_option('asm')
     49 with_osmesa = get_option('osmesa')
     50 with_swr_arches = get_option('swr-arches').split(',')
     51 if get_option('texture-float')
     52   pre_args += '-DTEXTURE_FLOAT_ENABLED'
     53   message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.')
     54 endif
     55 
     56 dri_drivers_path = get_option('dri-drivers-path')
     57 if dri_drivers_path == ''
     58   dri_drivers_path = join_paths(get_option('libdir'), 'dri')
     59 endif
     60 dri_search_path = get_option('dri-search-path')
     61 if dri_search_path == ''
     62   dri_search_path = join_paths(get_option('prefix'), dri_drivers_path)
     63 endif
     64 
     65 with_gles1 = get_option('gles1')
     66 with_gles2 = get_option('gles2')
     67 with_opengl = get_option('opengl')
     68 with_any_opengl = with_opengl or with_gles1 or with_gles2
     69 # Only build shared_glapi if at least one OpenGL API is enabled
     70 with_shared_glapi = get_option('shared-glapi') and with_any_opengl
     71 
     72 
     73 # shared-glapi is required if at least two OpenGL APIs are being built
     74 if not with_shared_glapi
     75   if ((with_gles1 and with_gles2) or (with_gles1 and with_opengl)
     76       or (with_gles2 and with_opengl))
     77     error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
     78   endif
     79 endif
     80 
     81 # We require OpenGL for OpenGL ES
     82 if (with_gles1 or with_gles2) and not with_opengl
     83   error('building OpenGL ES without OpenGL is not supported.')
     84 endif
     85 
     86 with_dri = false
     87 with_dri_i915 = false
     88 with_dri_i965 = false
     89 with_dri_r100 = false
     90 with_dri_r200 = false
     91 with_dri_nouveau = false
     92 with_dri_swrast = false
     93 _drivers = get_option('dri-drivers')
     94 if _drivers == 'auto'
     95   # TODO: PPC, Sparc
     96   if not ['darwin', 'windows'].contains(host_machine.system())
     97     if ['x86', 'x86_64'].contains(host_machine.cpu_family())
     98       _drivers = 'i915,i965,r100,r200,nouveau'
     99     else
    100       error('Unknown architecture. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
    101     endif
    102   else
    103     error('Unknown OS. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
    104   endif
    105 endif
    106 if _drivers != ''
    107   _split = _drivers.split(',')
    108   with_dri_i915 = _split.contains('i915')
    109   with_dri_i965 = _split.contains('i965')
    110   with_dri_r100 = _split.contains('r100')
    111   with_dri_r200 = _split.contains('r200')
    112   with_dri_nouveau = _split.contains('nouveau')
    113   with_dri_swrast = _split.contains('swrast')
    114   with_dri = true
    115 endif
    116 
    117 with_gallium = false
    118 with_gallium_pl111 = false
    119 with_gallium_radeonsi = false
    120 with_gallium_r300 = false
    121 with_gallium_r600 = false
    122 with_gallium_nouveau = false
    123 with_gallium_freedreno = false
    124 with_gallium_softpipe = false
    125 with_gallium_vc4 = false
    126 with_gallium_vc5 = false
    127 with_gallium_etnaviv = false
    128 with_gallium_imx = false
    129 with_gallium_i915 = false
    130 with_gallium_svga = false
    131 with_gallium_virgl = false
    132 with_gallium_swr = false
    133 _drivers = get_option('gallium-drivers')
    134 if _drivers == 'auto'
    135   if not ['darwin', 'windows'].contains(host_machine.system())
    136     # TODO: PPC, Sparc
    137     if ['x86', 'x86_64'].contains(host_machine.cpu_family())
    138       _drivers = 'r300,r600,radeonsi,nouveau,virgl,svga,swrast'
    139     elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
    140       _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,virgl,svga,swrast'
    141     else
    142       error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
    143     endif
    144   else
    145     error('Unknown OS. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
    146   endif
    147 endif
    148 if _drivers != ''
    149   _split = _drivers.split(',')
    150   with_gallium_pl111 = _split.contains('pl111')
    151   with_gallium_radeonsi = _split.contains('radeonsi')
    152   with_gallium_r300 = _split.contains('r300')
    153   with_gallium_r600 = _split.contains('r600')
    154   with_gallium_nouveau = _split.contains('nouveau')
    155   with_gallium_freedreno = _split.contains('freedreno')
    156   with_gallium_softpipe = _split.contains('swrast')
    157   with_gallium_vc4 = _split.contains('vc4')
    158   with_gallium_vc5 = _split.contains('vc5')
    159   with_gallium_etnaviv = _split.contains('etnaviv')
    160   with_gallium_imx = _split.contains('imx')
    161   with_gallium_i915 = _split.contains('i915')
    162   with_gallium_svga = _split.contains('svga')
    163   with_gallium_virgl = _split.contains('virgl')
    164   with_gallium_swr = _split.contains('swr')
    165   with_gallium = true
    166 endif
    167 
    168 with_intel_vk = false
    169 with_amd_vk = false
    170 with_any_vk = false
    171 _vulkan_drivers = get_option('vulkan-drivers')
    172 if _vulkan_drivers == 'auto'
    173   if not ['darwin', 'windows'].contains(host_machine.system())
    174     if host_machine.cpu_family().startswith('x86')
    175       _vulkan_drivers = 'amd,intel'
    176     else
    177       error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
    178     endif
    179   else
    180     # No vulkan driver supports windows or macOS currently
    181     _vulkan_drivers = ''
    182   endif
    183 endif
    184 if _vulkan_drivers != ''
    185   _split = _vulkan_drivers.split(',')
    186   with_intel_vk = _split.contains('intel')
    187   with_amd_vk = _split.contains('amd')
    188   with_any_vk = with_amd_vk or with_intel_vk
    189 endif
    190 
    191 if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
    192   error('Only one swrast provider can be built')
    193 endif
    194 if with_dri_i915 and with_gallium_i915
    195   error('Only one i915 provider can be built')
    196 endif
    197 if with_gallium_imx and not with_gallium_etnaviv
    198   error('IMX driver requires etnaviv driver')
    199 endif
    200 if with_gallium_pl111 and not with_gallium_vc4
    201   error('pl111 driver requires vc4 driver')
    202 endif
    203 
    204 dep_libdrm_intel = []
    205 if with_dri_i915 or with_gallium_i915
    206   dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
    207 endif
    208 
    209 system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'dragonfly', 'linux'].contains(host_machine.system())
    210 
    211 if host_machine.system() == 'darwin'
    212   with_dri_platform = 'apple'
    213 elif ['windows', 'cygwin'].contains(host_machine.system())
    214   with_dri_platform = 'windows'
    215 elif system_has_kms_drm
    216   with_dri_platform = 'drm'
    217 else
    218   # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
    219   # assert here that one of those cases has been met.
    220   # FIXME: GNU (hurd) ends up here as well, but meson doesn't officially
    221   # support Hurd at time of writing (2017/11)
    222   # FIXME: illumos ends up here as well
    223   with_dri_platform = 'none'
    224 endif
    225 
    226 with_platform_android = false
    227 with_platform_wayland = false
    228 with_platform_x11 = false
    229 with_platform_drm = false
    230 with_platform_surfaceless = false
    231 egl_native_platform = ''
    232 _platforms = get_option('platforms')
    233 if _platforms == 'auto'
    234   if system_has_kms_drm
    235     _platforms = 'x11,wayland,drm,surfaceless'
    236   else
    237     error('Unknown OS, no platforms enabled. Patches gladly accepted to fix this.')
    238   endif
    239 endif
    240 if _platforms != ''
    241   _split = _platforms.split(',')
    242   with_platform_android = _split.contains('android')
    243   with_platform_x11 = _split.contains('x11')
    244   with_platform_wayland = _split.contains('wayland')
    245   with_platform_drm = _split.contains('drm')
    246   with_platform_surfaceless = _split.contains('surfaceless')
    247   egl_native_platform = _split[0]
    248 endif
    249 
    250 with_glx = get_option('glx')
    251 if with_glx == 'auto'
    252   if with_dri
    253     with_glx = 'dri'
    254   elif with_gallium
    255     # Even when building just gallium drivers the user probably wants dri
    256     with_glx = 'dri'
    257   elif with_platform_x11 and with_any_opengl and not with_any_vk
    258     # The automatic behavior should not be to turn on xlib based glx when
    259     # building only vulkan drivers
    260     with_glx = 'xlib'
    261   else
    262     with_glx = 'disabled'
    263   endif
    264 endif
    265 if with_glx == 'dri'
    266    if with_gallium
    267       with_dri = true
    268    endif
    269 endif
    270 
    271 if not (with_dri or with_gallium or with_glx == 'xlib' or with_glx == 'gallium-xlib')
    272   with_gles1 = false
    273   with_gles2 = false
    274   with_opengl = false
    275   with_any_opengl = false
    276   with_shared_glapi = false
    277 endif
    278 
    279 with_gbm = get_option('gbm')
    280 if with_gbm == 'auto' and with_dri  # TODO: or gallium
    281   with_gbm = system_has_kms_drm
    282 elif with_gbm == 'true'
    283   if not system_has_kms_drm
    284     error('GBM only supports DRM/KMS platforms')
    285   endif
    286   with_gbm = true
    287 else
    288   with_gbm = false
    289 endif
    290 
    291 _egl = get_option('egl')
    292 if _egl == 'auto'
    293   with_egl = with_dri and with_shared_glapi and egl_native_platform != ''
    294 elif _egl == 'true'
    295   if not with_dri
    296     error('EGL requires dri')
    297   elif not with_shared_glapi
    298     error('EGL requires shared-glapi')
    299   elif egl_native_platform == ''
    300     error('No platforms specified, consider -Dplatforms=drm,x11 at least')
    301   endif
    302   with_egl = true
    303 else
    304   with_egl = false
    305 endif
    306 
    307 if with_egl and not (with_platform_drm or with_platform_surfaceless)
    308   if with_gallium_radeonsi
    309     error('RadeonSI requires drm or surfaceless platform when using EGL')
    310   endif
    311   if with_gallium_virgl
    312     error('Virgl requires drm or surfaceless platform when using EGL')
    313   endif
    314 endif
    315 
    316 pre_args += '-DGLX_USE_TLS'
    317 if with_glx != 'disabled'
    318   if not (with_platform_x11 and with_any_opengl)
    319     if with_glx == 'auto'
    320       with_glx = 'disabled'
    321     else
    322       error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
    323     endif
    324   elif with_glx == 'gallium-xlib' 
    325     if not with_gallium
    326       error('Gallium-xlib based GLX requires at least one gallium driver')
    327     elif not with_gallium_softpipe
    328       error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
    329     elif with_dri
    330       error('gallium-xlib conflicts with any dri driver')
    331     endif
    332   elif with_glx == 'xlib' 
    333     if with_dri
    334       error('xlib conflicts with any dri driver')
    335     endif
    336   elif with_glx == 'dri' and not with_dri
    337     error('dri based GLX requires at least one DRI driver')
    338   endif
    339 endif
    340 
    341 with_glvnd = get_option('glvnd')
    342 if with_glvnd
    343   if with_glx == 'xlib' or with_glx == 'gallium-xlib'
    344     error('Cannot build glvnd support for GLX that is not DRI based.')
    345   elif with_glx == 'disabled' and not with_egl
    346     error('glvnd requires DRI based GLX and/or EGL')
    347   endif
    348 endif
    349 
    350 # TODO: toggle for this
    351 with_glx_direct = true
    352 
    353 if with_vulkan_icd_dir == ''
    354   with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
    355 endif
    356 
    357 with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
    358 with_dri3 = get_option('dri3')
    359 if with_dri3 == 'auto'
    360   if system_has_kms_drm and with_dri2
    361     with_dri3 = true
    362   else
    363     with_dri3 = false
    364  endif
    365 elif with_dri3 == 'true'
    366   with_dri3 = true
    367 else
    368   with_dri3 = false
    369 endif
    370 
    371 if with_any_vk and (with_platform_x11 and not with_dri3)
    372   error('Vulkan drivers require dri3 for X11 support')
    373 endif
    374 if with_dri or with_gallium
    375   if with_glx == 'disabled' and not with_egl
    376     error('building dri or gallium drivers require at least one window system')
    377   endif
    378 endif
    379 
    380 prog_pkgconfig = find_program('pkg-config')
    381 
    382 _vdpau = get_option('gallium-vdpau')
    383 if not system_has_kms_drm
    384   if _vdpau == 'true'
    385     error('VDPAU state tracker can only be build on unix-like OSes.')
    386   else
    387     _vdpau = 'false'
    388   endif
    389 elif not with_platform_x11
    390   if _vdpau == 'true'
    391     error('VDPAU state tracker requires X11 support.')
    392   else
    393     _vdpau = 'false'
    394   endif
    395 elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
    396           with_gallium_nouveau)
    397   if _vdpau == 'true'
    398     error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.')
    399   else
    400     _vdpau = 'false'
    401   endif
    402 elif _vdpau == 'auto'
    403   _vdpau = 'true'
    404 endif
    405 with_gallium_vdpau = _vdpau == 'true'
    406 dep_vdpau = []
    407 if with_gallium_vdpau
    408   dep_vdpau = dependency('vdpau', version : '>= 1.1')
    409   dep_vdpau = declare_dependency(
    410     compile_args : run_command(prog_pkgconfig, ['vdpau', '--cflags']).stdout().split()
    411   )
    412 endif
    413 
    414 if with_gallium_vdpau
    415   pre_args += '-DHAVE_ST_VDPAU'
    416 endif
    417 vdpau_drivers_path = get_option('vdpau-libs-path')
    418 if vdpau_drivers_path == ''
    419   vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
    420 endif
    421 
    422 _xvmc = get_option('gallium-xvmc')
    423 if not system_has_kms_drm
    424   if _xvmc == 'true'
    425     error('XVMC state tracker can only be build on unix-like OSes.')
    426   else
    427     _xvmc = 'false'
    428   endif
    429 elif not with_platform_x11
    430   if _xvmc == 'true'
    431     error('XVMC state tracker requires X11 support.')
    432   else
    433     _xvmc = 'false'
    434   endif
    435 elif not (with_gallium_r600 or with_gallium_nouveau)
    436   if _xvmc == 'true'
    437     error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.')
    438   else
    439     _xvmc = 'false'
    440   endif
    441 elif _xvmc == 'auto'
    442   _xvmc = 'true'
    443 endif
    444 with_gallium_xvmc = _xvmc == 'true'
    445 dep_xvmc = []
    446 if with_gallium_xvmc
    447   dep_xvmc = dependency('xvmc', version : '>= 1.0.6')
    448 endif
    449 
    450 xvmc_drivers_path = get_option('xvmc-libs-path')
    451 if xvmc_drivers_path == ''
    452   xvmc_drivers_path = get_option('libdir')
    453 endif
    454 
    455 _omx = get_option('gallium-omx')
    456 if not system_has_kms_drm
    457   if _omx == 'true'
    458     error('OMX state tracker can only be built on unix-like OSes.')
    459   else
    460     _omx = 'false'
    461   endif
    462 elif not (with_platform_x11 or with_platform_drm)
    463   if _omx == 'true'
    464     error('OMX state tracker requires X11 or drm platform support.')
    465   else
    466     _omx = 'false'
    467   endif
    468 elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
    469   if _omx == 'true'
    470     error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
    471   else
    472     _omx = 'false'
    473   endif
    474 elif _omx == 'auto'
    475   _omx = 'true'
    476 endif
    477 with_gallium_omx = _omx == 'true'
    478 dep_omx = []
    479 if with_gallium_omx
    480   dep_omx = dependency('libomxil-bellagio')
    481 endif
    482 
    483 omx_drivers_path = get_option('omx-libs-path')
    484 if with_gallium_omx
    485   # Figure out where to put the omx driver.
    486   # FIXME: this could all be vastly simplified by adding a 'defined_variable'
    487   # argument to meson's get_pkgconfig_variable method.
    488   if omx_drivers_path == ''
    489     _omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
    490     _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
    491     if _omx_libdir == get_option('libdir')
    492       omx_drivers_path = _omx_drivers_dir
    493     else
    494       _omx_base_dir = []
    495       # This will fail on windows. Does OMX run on windows?
    496       _omx_libdir = _omx_libdir.split('/')
    497       _omx_drivers_dir = _omx_drivers_dir.split('/')
    498       foreach o : _omx_drivers_dir
    499         if not _omx_libdir.contains(o)
    500           _omx_base_dir += o
    501         endif
    502       endforeach
    503       omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
    504     endif
    505   endif
    506 endif
    507 
    508 _va = get_option('gallium-va')
    509 if not system_has_kms_drm
    510   if _va == 'true'
    511     error('VA state tracker can only be built on unix-like OSes.')
    512   else
    513     _va = 'false'
    514   endif
    515 elif not (with_platform_x11 or with_platform_drm)
    516   if _va == 'true'
    517     error('VA state tracker requires X11 or drm or wayland platform support.')
    518   else
    519     _va = 'false'
    520   endif
    521 elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
    522   if _va == 'true'
    523     error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
    524   else
    525     _va = 'false'
    526   endif
    527 elif _va == 'auto'
    528   _va = 'true'
    529 endif
    530 with_gallium_va = _va == 'true'
    531 dep_va = []
    532 if with_gallium_va
    533   dep_va = dependency('libva', version : '>= 0.38.0')
    534   dep_va_headers = declare_dependency(
    535     compile_args : run_command(prog_pkgconfig, ['libva', '--cflags']).stdout().split()
    536   )
    537 endif
    538 
    539 va_drivers_path = get_option('va-libs-path')
    540 if va_drivers_path == ''
    541   va_drivers_path = join_paths(get_option('libdir'), 'dri')
    542 endif
    543 
    544 _xa = get_option('gallium-xa')
    545 if not system_has_kms_drm
    546   if _xa == 'true'
    547     error('XA state tracker can only be built on unix-like OSes.')
    548   else
    549     _xa = 'false'
    550   endif
    551 elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
    552           or with_gallium_svga)
    553   if _xa == 'true'
    554     error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.')
    555   else
    556     _xa = 'false'
    557   endif
    558 endif
    559 with_gallium_xa = _xa != 'false'
    560 
    561 d3d_drivers_path = get_option('d3d-drivers-path')
    562 if d3d_drivers_path == ''
    563   d3d_drivers_path = join_paths(get_option('libdir'), 'd3d')
    564 endif
    565 
    566 with_gallium_st_nine =  get_option('gallium-nine')
    567 if with_gallium_st_nine
    568   if not with_gallium_softpipe
    569     error('The nine state tracker requires gallium softpipe/llvmpipe.')
    570   elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600
    571             or with_gallium_r300 or with_gallium_svga or with_gallium_i915)
    572     error('The nine state tracker requires at least on non-swrast gallium driver.')
    573   endif
    574   if not with_dri3
    575     error('Using nine with wine requires dri3')
    576   endif
    577 endif
    578 
    579 _opencl = get_option('gallium-opencl')
    580 if _opencl != 'disabled'
    581   if not with_gallium
    582     error('OpenCL Clover implementation requires at least one gallium driver.')
    583   endif
    584 
    585   # TODO: alitvec?
    586   dep_clc = dependency('libclc')
    587   with_gallium_opencl = true
    588   with_opencl_icd = _opencl == 'icd'
    589 else
    590   dep_clc = []
    591   with_gallium_opencl = false
    592   with_gallium_icd = false
    593 endif
    594 
    595 gl_pkgconfig_c_flags = []
    596 if with_platform_x11
    597   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
    598     pre_args += '-DHAVE_X11_PLATFORM'
    599   endif
    600   if with_glx == 'xlib' or with_glx == 'gallium-xlib'
    601     pre_args += '-DUSE_XSHM'
    602   else
    603     pre_args += '-DGLX_INDIRECT_RENDERING'
    604     if with_glx_direct
    605       pre_args += '-DGLX_DIRECT_RENDERING'
    606     endif
    607     if with_dri_platform == 'drm'
    608       pre_args += '-DGLX_USE_DRM'
    609     elif with_dri_platform == 'windows'
    610       pre_args += '-DGLX_USE_WINDOWSGL'
    611     endif
    612   endif
    613 else
    614   pre_args += '-DMESA_EGL_NO_X11_HEADERS'
    615   gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS'
    616 endif
    617 if with_platform_drm
    618   if with_egl and not with_gbm
    619     error('EGL drm platform requires gbm')
    620   endif
    621   pre_args += '-DHAVE_DRM_PLATFORM'
    622 endif
    623 if with_platform_surfaceless
    624   pre_args += '-DHAVE_SURFACELESS_PLATFORM'
    625 endif
    626 if with_platform_android
    627   dep_android = [
    628     dependency('cutils'),
    629     dependency('hardware'),
    630     dependency('sync'),
    631   ]
    632   pre_args += '-DHAVE_ANDROID_PLATFORM'
    633 endif
    634 
    635 prog_python2 = find_program('python2')
    636 has_mako = run_command(prog_python2, '-c', 'import mako')
    637 if has_mako.returncode() != 0
    638   error('Python (2.x) mako module required to build mesa.')
    639 endif
    640 
    641 cc = meson.get_compiler('c')
    642 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
    643   error('When using GCC, version 4.4.6 or later is required.')
    644 endif
    645 
    646 # Define DEBUG for debug builds only (debugoptimized is not included on this one)
    647 if get_option('buildtype') == 'debug'
    648   pre_args += '-DDEBUG'
    649 endif
    650 
    651 if get_option('shader-cache')
    652   pre_args += '-DENABLE_SHADER_CACHE'
    653 elif with_amd_vk
    654   error('Radv requires shader cache support')
    655 endif
    656 
    657 # Check for GCC style builtins
    658 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
    659              'ffsll', 'popcount', 'popcountll', 'unreachable']
    660   if cc.has_function(b)
    661     pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
    662   endif
    663 endforeach
    664 
    665 # check for GCC __attribute__
    666 foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
    667              'warn_unused_result', 'weak',]
    668   if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
    669                  name : '__attribute__((@0@))'.format(a))
    670     pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
    671   endif
    672 endforeach
    673 if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
    674                name : '__attribute__((format(...)))')
    675   pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
    676 endif
    677 if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
    678                name : '__attribute__((packed))')
    679   pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
    680 endif
    681 if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
    682                name : '__attribute__((returns_nonnull))')
    683   pre_args += '-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL'
    684 endif
    685 if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
    686                   int foo_hid(void) __attribute__((visibility("hidden")));
    687                   int foo_int(void) __attribute__((visibility("internal")));
    688                   int foo_pro(void) __attribute__((visibility("protected")));''',
    689                name : '__attribute__((visibility(...)))')
    690   pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
    691 endif
    692 if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
    693                name : '__attribute__((alias(...)))')
    694   pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
    695 endif
    696 if cc.compiles('int foo(void) __attribute__((__noreturn__));',
    697                name : '__attribute__((__noreturn__))')
    698   pre_args += '-DHAVE_FUNC_ATTRIBUTE_NORETURN'
    699 endif
    700 
    701 # TODO: this is very incomplete
    702 if ['linux', 'cygwin'].contains(host_machine.system())
    703   pre_args += '-D_GNU_SOURCE'
    704 endif
    705 
    706 # Check for generic C arguments
    707 c_args = []
    708 foreach a : ['-Wall', '-Werror=implicit-function-declaration',
    709              '-Werror=missing-prototypes', '-fno-math-errno',
    710              '-fno-trapping-math', '-Qunused-arguments']
    711   if cc.has_argument(a)
    712     c_args += a
    713   endif
    714 endforeach
    715 c_vis_args = []
    716 if cc.has_argument('-fvisibility=hidden')
    717   c_vis_args += '-fvisibility=hidden'
    718 endif
    719 
    720 # Check for generic C++ arguments
    721 cpp = meson.get_compiler('cpp')
    722 cpp_args = []
    723 foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
    724              '-Qunused-arguments']
    725   if cpp.has_argument(a)
    726     cpp_args += a
    727   endif
    728 endforeach
    729 
    730 # For some reason, the test for -Wno-foo always succeeds with gcc, even if the
    731 # option is not supported. Hence, check for -Wfoo instead.
    732 if cpp.has_argument('-Wnon-virtual-dtor')
    733   cpp_args += '-Wno-non-virtual-dtor'
    734 endif
    735 
    736 no_override_init_args = []
    737 foreach a : ['override-init', 'initializer-overrides']
    738   if cc.has_argument('-W' + a)
    739     no_override_init_args += '-Wno-' + a
    740   endif
    741 endforeach
    742 
    743 cpp_vis_args = []
    744 if cpp.has_argument('-fvisibility=hidden')
    745   cpp_vis_args += '-fvisibility=hidden'
    746 endif
    747 
    748 # Check for C and C++ arguments for MSVC2013 compatibility. These are only used
    749 # in parts of the mesa code base that need to compile with old versions of
    750 # MSVC, mainly common code
    751 c_msvc_compat_args = []
    752 cpp_msvc_compat_args = []
    753 foreach a : ['-Werror=pointer-arith', '-Werror=vla']
    754   if cc.has_argument(a)
    755     c_msvc_compat_args += a
    756   endif
    757   if cpp.has_argument(a)
    758     cpp_msvc_compat_args += a
    759   endif
    760 endforeach
    761 
    762 if host_machine.cpu_family().startswith('x86')
    763   pre_args += '-DUSE_SSE41'
    764   with_sse41 = true
    765   sse41_args = ['-msse4.1']
    766 
    767   # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
    768   # that's not guaranteed
    769   if host_machine.cpu_family() == 'x86'
    770     sse41_args += '-mstackrealign'
    771   endif
    772 else
    773   with_sse41 = false
    774   sse41_args = []
    775 endif
    776 
    777 # Check for GCC style atomics
    778 if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
    779                name : 'GCC atomic builtins')
    780   pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
    781 endif
    782 if not cc.links('''#include <stdint.h>
    783                    uint64_t v;
    784                    int main() {
    785                      return __sync_add_and_fetch(&v, (uint64_t)1);
    786                    }''',
    787                 name : 'GCC 64bit atomics')
    788   pre_args += '-DMISSING_64_BIT_ATOMICS'
    789 endif
    790 
    791 # TODO: endian
    792 # TODO: powr8
    793 # TODO: shared/static? Is this even worth doing?
    794 
    795 # Building x86 assembly code requires running x86 binaries. It is possible for
    796 # x86_64 OSes to run x86 binaries, so don't disable asm in those cases
    797 # TODO: it should be possible to use an exe_wrapper to run the binary during
    798 # the build. 
    799 if meson.is_cross_build() 
    800   if not (build_machine.cpu_family() == 'x86_64' and host_machine.cpu_family() == 'x86'
    801           and build_machine.system() == host_machine.system())
    802     message('Cross compiling to x86 from non-x86, disabling asm')
    803     with_asm = false
    804   endif
    805 endif
    806 
    807 with_asm_arch = ''
    808 if with_asm
    809   # TODO: SPARC and PPC
    810   if host_machine.cpu_family() == 'x86'
    811     if system_has_kms_drm
    812       with_asm_arch = 'x86'
    813       pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
    814                    '-DUSE_SSE_ASM']
    815     endif
    816   elif host_machine.cpu_family() == 'x86_64'
    817     if system_has_kms_drm
    818       with_asm_arch = 'x86_64'
    819       pre_args += ['-DUSE_X86_64_ASM']
    820     endif
    821   elif host_machine.cpu_family() == 'arm'
    822     if system_has_kms_drm
    823       with_asm_arch = 'arm'
    824       pre_args += ['-DUSE_ARM_ASM']
    825     endif
    826   elif host_machine.cpu_family() == 'aarch64'
    827     if system_has_kms_drm
    828       with_asm_arch = 'aarch64'
    829       pre_args += ['-DUSE_AARCH64_ASM']
    830     endif
    831   endif
    832 endif
    833 
    834 # Check for standard headers and functions
    835 if cc.has_header_symbol('sys/sysmacros.h', 'major')
    836   pre_args += '-DMAJOR_IN_SYSMACROS'
    837 elif cc.has_header_symbol('sys/mkdev.h', 'major')
    838   pre_args += '-DMAJOR_IN_MKDEV'
    839 endif
    840 
    841 foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h']
    842   if cc.compiles('#include <@0@>'.format(h), name : '@0@ works'.format(h))
    843     pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
    844   endif
    845 endforeach
    846 
    847 foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create']
    848   if cc.has_function(f)
    849     pre_args += '-DHAVE_@0@'.format(f.to_upper())
    850   endif
    851 endforeach
    852 
    853 # strtod locale support
    854 if cc.links('''
    855     #define _GNU_SOURCE
    856     #include <stdlib.h>
    857     #include <locale.h>
    858     #ifdef HAVE_XLOCALE_H
    859     #include <xlocale.h>
    860     #endif
    861     int main() {
    862       locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
    863       const char *s = "1.0";
    864       char *end;
    865       double d = strtod_l(s, end, loc);
    866       float f = strtof_l(s, end, loc);
    867       freelocale(loc);
    868       return 0;
    869     }''',
    870     extra_args : pre_args,
    871     name : 'strtod has locale support')
    872   pre_args += '-DHAVE_STRTOD_L'
    873 endif
    874 
    875 # Check for some linker flags
    876 ld_args_bsymbolic = []
    877 if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
    878   ld_args_bsymbolic += '-Wl,-Bsymbolic'
    879 endif
    880 ld_args_gc_sections = []
    881 if cc.links('static char unused() { return 5; } int main() { return 0; }',
    882             args : '-Wl,--gc-sections', name : 'gc-sections')
    883   ld_args_gc_sections += '-Wl,--gc-sections'
    884 endif
    885 with_ld_version_script = false
    886 if cc.links('int main() { return 0; }',
    887             args : '-Wl,--version-script=@0@'.format(
    888               join_paths(meson.source_root(), 'build-support/conftest.map')),
    889             name : 'version-script')
    890   with_ld_version_script = true
    891 endif
    892 with_ld_dynamic_list = false
    893 if cc.links('int main() { return 0; }',
    894             args : '-Wl,--dynamic-list=@0@'.format(
    895               join_paths(meson.source_root(), 'build-support/conftest.dyn')),
    896             name : 'dynamic-list')
    897   with_ld_dynamic_list = true
    898 endif
    899 
    900 # check for dl support
    901 if cc.has_function('dlopen')
    902   dep_dl = []
    903 else
    904   dep_dl = cc.find_library('dl')
    905 endif
    906 if cc.has_function('dladdr', dependencies : dep_dl)
    907   # This is really only required for megadrivers
    908   pre_args += '-DHAVE_DLADDR'
    909 endif
    910 
    911 if cc.has_function('dl_iterate_phdr')
    912   pre_args += '-DHAVE_DL_ITERATE_PHDR'
    913 elif with_intel_vk
    914   error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
    915 elif with_dri_i965 and get_option('shader-cache')
    916   error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
    917 endif
    918 
    919 # Determine whether or not the rt library is needed for time functions
    920 if cc.has_function('clock_gettime')
    921   dep_clock = []
    922 else
    923   dep_clock = cc.find_library('rt')
    924 endif
    925 
    926 with_gallium_drisw_kms = false
    927 dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
    928                         required : with_dri2 or with_dri3)
    929 if dep_libdrm.found()
    930   pre_args += '-DHAVE_LIBDRM'
    931   if with_dri_platform == 'drm' and with_dri
    932     with_gallium_drisw_kms = true
    933   endif
    934 endif
    935 
    936 # TODO: some of these may be conditional
    937 dep_zlib = dependency('zlib', version : '>= 1.2.3')
    938 pre_args += '-DHAVE_ZLIB'
    939 dep_thread = dependency('threads')
    940 if dep_thread.found() and host_machine.system() != 'windows'
    941   pre_args += '-DHAVE_PTHREAD'
    942 endif
    943 if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or with_gallium_opencl
    944   dep_elf = dependency('libelf', required : false)
    945   if not dep_elf.found()
    946     dep_elf = cc.find_library('elf')
    947   endif
    948 else
    949   dep_elf = []
    950 endif
    951 dep_expat = dependency('expat')
    952 # this only exists on linux so either this is linux and it will be found, or
    953 # its not linux and and wont
    954 dep_m = cc.find_library('m', required : false)
    955 
    956 dep_libdrm_amdgpu = []
    957 dep_libdrm_radeon = []
    958 dep_libdrm_nouveau = []
    959 dep_libdrm_etnaviv = []
    960 dep_libdrm_freedreno = []
    961 if with_amd_vk or with_gallium_radeonsi
    962   dep_libdrm_amdgpu = dependency(
    963     'libdrm_amdgpu', version : ['>= 2.4.89', '!= 2.4.90']
    964   )
    965 endif
    966 if (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
    967     with_gallium_r300 or with_gallium_r600)
    968   dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
    969 endif
    970 if with_gallium_nouveau or with_dri_nouveau
    971   dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
    972 endif
    973 if with_gallium_etnaviv
    974   dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
    975 endif
    976 if with_gallium_freedreno
    977   dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.89')
    978 endif
    979 
    980 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
    981 if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
    982   llvm_modules += ['amdgpu', 'bitreader', 'ipo']
    983   if with_gallium_r600
    984     llvm_modules += 'asmparser'
    985   endif
    986 endif
    987 if with_gallium_opencl
    988   llvm_modules += [
    989     'all-targets', 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
    990     'lto', 'option', 'objcarcopts', 'profiledata',
    991   ]
    992   # TODO: optional modules
    993 endif
    994 
    995 if with_amd_vk
    996   _llvm_version = '>= 4.0.0'
    997 elif with_gallium_opencl or with_gallium_swr or with_gallium_r600 or with_gallium_radeonsi
    998   _llvm_version = '>= 3.9.0'
    999 else
   1000   _llvm_version = '>= 3.3.0'
   1001 endif
   1002 
   1003 _llvm = get_option('llvm')
   1004 if _llvm == 'auto'
   1005   dep_llvm = dependency(
   1006     'llvm', version : _llvm_version, modules : llvm_modules,
   1007     required : with_amd_vk or with_gallium_radeonsi or with_gallium_swr or with_gallium_opencl,
   1008   )
   1009   with_llvm = dep_llvm.found()
   1010 elif _llvm == 'true'
   1011   dep_llvm = dependency('llvm', version : _llvm_version, modules : llvm_modules)
   1012   with_llvm = true
   1013 else
   1014   dep_llvm = []
   1015   with_llvm = false
   1016 endif
   1017 if with_llvm
   1018   _llvm_version = dep_llvm.version().split('.')
   1019   # Development versions of LLVM have an 'svn' or 'git' suffix, we don't want
   1020   # that for our version checks.
   1021   # svn suffixes are stripped by meson as of 0.43, and git suffixes are
   1022   # strippped as of 0.44, but we support older meson versions.
   1023   _llvm_patch = _llvm_version[2]
   1024   if _llvm_patch.endswith('svn')
   1025     _llvm_patch = _llvm_patch.split('s')[0]
   1026   elif _llvm_patch.contains('git')
   1027     _llvm_patch = _llvm_patch.split('g')[0]
   1028   endif
   1029   pre_args += [
   1030     '-DHAVE_LLVM=0x0@0@0@1@'.format(_llvm_version[0], _llvm_version[1]),
   1031     '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
   1032   ]
   1033 elif with_amd_vk or with_gallium_radeonsi or with_gallium_swr
   1034   error('The following drivers requires LLVM: Radv, RadeonSI, SWR. One of these is enabled, but LLVM is disabled.')
   1035 endif
   1036 
   1037 dep_glvnd = []
   1038 if with_glvnd
   1039   dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
   1040   pre_args += '-DUSE_LIBGLVND=1'
   1041 endif
   1042 
   1043 if with_valgrind != 'false'
   1044   dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
   1045   if dep_valgrind.found()
   1046     pre_args += '-DHAVE_VALGRIND'
   1047   endif
   1048 else
   1049   dep_valgrind = []
   1050 endif
   1051 
   1052 # pthread stubs. Lets not and say we didn't
   1053 
   1054 prog_bison = find_program('bison', required : with_any_opengl)
   1055 prog_flex = find_program('flex', required : with_any_opengl)
   1056 
   1057 dep_selinux = []
   1058 if get_option('selinux')
   1059   dep_selinux = dependency('libselinux')
   1060   pre_args += '-DMESA_SELINUX'
   1061 endif
   1062 
   1063 # TODO: llvm-prefix and llvm-shared-libs
   1064 
   1065 if with_libunwind != 'false'
   1066   dep_unwind = dependency('libunwind', required : with_libunwind == 'true')
   1067   if dep_unwind.found()
   1068     pre_args += '-DHAVE_LIBUNWIND'
   1069   endif
   1070 else
   1071   dep_unwind = []
   1072 endif
   1073 
   1074 # TODO: gallium-hud
   1075 
   1076 if with_osmesa != 'none'
   1077   if with_osmesa == 'classic' and not with_dri_swrast
   1078     error('OSMesa classic requires dri (classic) swrast.')
   1079   endif
   1080   if with_osmesa == 'gallium' and not with_gallium_softpipe
   1081     error('OSMesa gallium requires gallium softpipe or llvmpipe.')
   1082   endif
   1083   osmesa_lib_name = 'OSMesa'
   1084   osmesa_bits = get_option('osmesa-bits')
   1085   if osmesa_bits != '8'
   1086     if with_dri or with_glx != 'disabled'
   1087       error('OSMesa bits must be 8 if building glx or dir based drivers')
   1088     endif
   1089     osmesa_lib_name = osmesa_lib_name + osmesa_bits
   1090     pre_args += [
   1091       '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
   1092     ]
   1093   endif
   1094 endif
   1095 
   1096 # TODO: symbol mangling
   1097 
   1098 if with_platform_wayland
   1099   prog_wl_scanner = find_program('wayland-scanner')
   1100   dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
   1101   dep_wayland_client = dependency('wayland-client', version : '>=1.11')
   1102   dep_wayland_server = dependency('wayland-server', version : '>=1.11')
   1103   wayland_dmabuf_xml = join_paths(
   1104     dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
   1105     'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
   1106   )
   1107   pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
   1108 else
   1109   prog_wl_scanner = []
   1110   dep_wl_protocols = []
   1111   dep_wayland_client = []
   1112   dep_wayland_server = []
   1113   wayland_dmabuf_xml = ''
   1114 endif
   1115 
   1116 dep_x11 = []
   1117 dep_xext = []
   1118 dep_xdamage = []
   1119 dep_xfixes = []
   1120 dep_x11_xcb = []
   1121 dep_xcb = []
   1122 dep_xcb_glx = []
   1123 dep_xcb_dri2 = []
   1124 dep_xcb_dri3 = []
   1125 dep_dri2proto = []
   1126 dep_glproto = []
   1127 dep_xxf86vm = []
   1128 dep_xcb_dri3 = []
   1129 dep_xcb_present = []
   1130 dep_xcb_sync = []
   1131 dep_xcb_xfixes = []
   1132 dep_xshmfence = []
   1133 if with_platform_x11
   1134   if with_glx == 'xlib' or with_glx == 'gallium-xlib'
   1135     dep_x11 = dependency('x11')
   1136     dep_xext = dependency('xext')
   1137     dep_xcb = dependency('xcb')
   1138   elif with_glx == 'dri'
   1139     dep_x11 = dependency('x11')
   1140     dep_xext = dependency('xext')
   1141     dep_xdamage = dependency('xdamage', version : '>= 1.1')
   1142     dep_xfixes = dependency('xfixes')
   1143     dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
   1144     dep_xxf86vm = dependency('xxf86vm', required : false)
   1145   endif
   1146   if (with_any_vk or with_glx == 'dri' or
   1147        (with_gallium_vdpau or with_gallium_xvmc or with_gallium_omx or
   1148         with_gallium_xa))
   1149     dep_xcb = dependency('xcb')
   1150     dep_x11_xcb = dependency('x11-xcb')
   1151   endif
   1152   if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
   1153     dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
   1154 
   1155     if with_dri3
   1156       pre_args += '-DHAVE_DRI3'
   1157       dep_xcb_dri3 = dependency('xcb-dri3')
   1158       dep_xcb_present = dependency('xcb-present')
   1159       dep_xcb_sync = dependency('xcb-sync')
   1160       dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
   1161     endif
   1162   endif
   1163   if with_glx == 'dri'
   1164     if with_dri_platform == 'drm'
   1165       dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
   1166     endif
   1167     dep_glproto = dependency('glproto', version : '>= 1.4.14')
   1168   endif
   1169   if with_egl
   1170     dep_xcb_xfixes = dependency('xcb-xfixes')
   1171   endif
   1172 endif
   1173 
   1174 if get_option('gallium-extra-hud')
   1175   pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
   1176 endif
   1177 
   1178 _sensors = get_option('lmsensors')
   1179 if _sensors != 'false'
   1180   dep_lmsensors = cc.find_library('libsensors', required : _sensors == 'true')
   1181   if dep_lmsensors.found()
   1182     pre_args += '-DHAVE_LIBSENSORS=1'
   1183   endif
   1184 else
   1185   dep_lmsensors = []
   1186 endif
   1187 
   1188 # TODO: gallium tests
   1189 
   1190 # TODO: various libdirs
   1191 
   1192 # TODO: gallium driver dirs
   1193 
   1194 # FIXME: this is a workaround for #2326
   1195 prog_touch = find_program('touch')
   1196 dummy_cpp = custom_target(
   1197   'dummy_cpp',
   1198   output : 'dummy.cpp',
   1199   command : [prog_touch, '@OUTPUT@'],
   1200 )
   1201 
   1202 foreach a : pre_args
   1203   add_project_arguments(a, language : ['c', 'cpp'])
   1204 endforeach
   1205 foreach a : c_args
   1206   add_project_arguments(a, language : ['c'])
   1207 endforeach
   1208 foreach a : cpp_args
   1209   add_project_arguments(a, language : ['cpp'])
   1210 endforeach
   1211 
   1212 inc_include = include_directories('include')
   1213 
   1214 gl_priv_reqs = [
   1215   'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
   1216   'xcb-glx >= 1.8.1']
   1217 if dep_libdrm.found()
   1218   gl_priv_reqs += 'libdrm >= 2.4.75'
   1219 endif
   1220 if dep_xxf86vm != [] and dep_xxf86vm.found()
   1221   gl_priv_reqs += 'xxf86vm'
   1222 endif
   1223 if with_dri_platform == 'drm'
   1224   gl_priv_reqs += 'xcb-dri2 >= 1.8'
   1225 endif
   1226 
   1227 gl_priv_libs = []
   1228 if dep_thread.found()
   1229   gl_priv_libs += ['-lpthread', '-pthread']
   1230 endif
   1231 if dep_m.found()
   1232   gl_priv_libs += '-lm'
   1233 endif
   1234 if dep_dl != [] and dep_dl.found()
   1235   gl_priv_libs += '-ldl'
   1236 endif
   1237 
   1238 pkg = import('pkgconfig')
   1239 
   1240 subdir('include')
   1241 subdir('bin')
   1242 subdir('src')
   1243