+prog_pkgconfig = find_program('pkg-config')
+
+_vdpau = get_option('gallium-vdpau')
+if not system_has_kms_drm
+ if _vdpau == 'true'
+ error('VDPAU state tracker can only be build on unix-like OSes.')
+ else
+ _vdpau = 'false'
+ endif
+elif not with_platform_x11
+ if _vdpau == 'true'
+ error('VDPAU state tracker requires X11 support.')
+ else
+ _vdpau = 'false'
+ endif
+elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
+ with_gallium_nouveau)
+ if _vdpau == 'true'
+ error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.')
+ else
+ _vdpau = 'false'
+ endif
+elif _vdpau == 'auto'
+ _vdpau = 'true'
+endif
+with_gallium_vdpau = _vdpau == 'true'
+dep_vdpau = null_dep
+if with_gallium_vdpau
+ dep_vdpau = dependency('vdpau', version : '>= 1.1')
+ dep_vdpau = declare_dependency(
+ compile_args : run_command(prog_pkgconfig, ['vdpau', '--cflags']).stdout().split()
+ )
+endif
+
+if with_gallium_vdpau
+ pre_args += '-DHAVE_ST_VDPAU'
+endif
+vdpau_drivers_path = get_option('vdpau-libs-path')
+if vdpau_drivers_path == ''
+ vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
+endif
+
+_xvmc = get_option('gallium-xvmc')
+if not system_has_kms_drm
+ if _xvmc == 'true'
+ error('XVMC state tracker can only be build on unix-like OSes.')
+ else
+ _xvmc = 'false'
+ endif
+elif not with_platform_x11
+ if _xvmc == 'true'
+ error('XVMC state tracker requires X11 support.')
+ else
+ _xvmc = 'false'
+ endif
+elif not (with_gallium_r600 or with_gallium_nouveau)
+ if _xvmc == 'true'
+ error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.')
+ else
+ _xvmc = 'false'
+ endif
+elif _xvmc == 'auto'
+ _xvmc = 'true'
+endif
+with_gallium_xvmc = _xvmc == 'true'
+dep_xvmc = null_dep
+if with_gallium_xvmc
+ dep_xvmc = dependency('xvmc', version : '>= 1.0.6')
+endif
+
+xvmc_drivers_path = get_option('xvmc-libs-path')
+if xvmc_drivers_path == ''
+ xvmc_drivers_path = get_option('libdir')
+endif
+
+_omx = get_option('gallium-omx')
+if not system_has_kms_drm
+ if ['auto', 'disabled'].contains(_omx)
+ _omx = 'disabled'
+ else
+ error('OMX state tracker can only be built on unix-like OSes.')
+ endif
+elif not (with_platform_x11 or with_platform_drm)
+ if ['auto', 'disabled'].contains(_omx)
+ _omx = 'disabled'
+ else
+ error('OMX state tracker requires X11 or drm platform support.')
+ endif
+elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
+ if ['auto', 'disabled'].contains(_omx)
+ _omx = 'disabled'
+ else
+ error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
+ endif
+endif
+with_gallium_omx = _omx
+dep_omx = null_dep
+dep_omx_other = []
+if ['auto', 'bellagio'].contains(_omx)
+ dep_omx = dependency(
+ 'libomxil-bellagio', required : _omx == 'bellagio'
+ )
+ if dep_omx.found()
+ with_gallium_omx = 'bellagio'
+ endif
+endif
+if ['auto', 'tizonia'].contains(_omx)
+ if with_dri and with_egl
+ dep_omx = dependency(
+ 'libtizonia', version : '>= 0.10.0',
+ required : _omx == 'tizonia',
+ )
+ dep_omx_other = [
+ dependency('libtizplatform', required : _omx == 'tizonia'),
+ dependency('tizilheaders', required : _omx == 'tizonia'),
+ ]
+ if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
+ with_gallium_omx = 'tizonia'
+ endif
+ elif _omx == 'tizonia'
+ error('OMX-Tizonia state tracker requires dri and egl')
+ endif
+endif
+if _omx == 'auto'
+ with_gallium_omx = 'disabled'
+else
+ with_gallium_omx = _omx
+endif
+
+pre_args += [
+ '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'),
+ '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'),
+]
+
+
+omx_drivers_path = get_option('omx-libs-path')
+
+if with_gallium_omx != 'disabled'
+ # Figure out where to put the omx driver.
+ # FIXME: this could all be vastly simplified by adding a 'defined_variable'
+ # argument to meson's get_pkgconfig_variable method.
+ if omx_drivers_path == ''
+ _omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
+ _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
+ if _omx_libdir == get_option('libdir')
+ omx_drivers_path = _omx_drivers_dir
+ else
+ _omx_base_dir = []
+ # This will fail on windows. Does OMX run on windows?
+ _omx_libdir = _omx_libdir.split('/')
+ _omx_drivers_dir = _omx_drivers_dir.split('/')
+ foreach o : _omx_drivers_dir
+ if not _omx_libdir.contains(o)
+ _omx_base_dir += o
+ endif
+ endforeach
+ omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
+ endif
+ endif
+endif
+
+_va = get_option('gallium-va')
+if not system_has_kms_drm
+ if _va == 'true'
+ error('VA state tracker can only be built on unix-like OSes.')
+ else
+ _va = 'false'
+ endif
+elif not (with_platform_x11 or with_platform_drm)
+ if _va == 'true'
+ error('VA state tracker requires X11 or drm or wayland platform support.')
+ else
+ _va = 'false'
+ endif
+elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
+ if _va == 'true'
+ error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
+ else
+ _va = 'false'
+ endif
+elif _va == 'auto'
+ _va = 'true'
+endif
+with_gallium_va = _va == 'true'
+dep_va = null_dep
+if with_gallium_va
+ dep_va = dependency('libva', version : '>= 0.38.0')
+ dep_va_headers = declare_dependency(
+ compile_args : run_command(prog_pkgconfig, ['libva', '--cflags']).stdout().split()
+ )
+endif
+
+va_drivers_path = get_option('va-libs-path')
+if va_drivers_path == ''
+ va_drivers_path = join_paths(get_option('libdir'), 'dri')
+endif
+
+_xa = get_option('gallium-xa')
+if not system_has_kms_drm
+ if _xa == 'true'
+ error('XA state tracker can only be built on unix-like OSes.')
+ else
+ _xa = 'false'
+ endif
+elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
+ or with_gallium_svga)
+ if _xa == 'true'
+ error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.')
+ else
+ _xa = 'false'
+ endif
+endif
+with_gallium_xa = _xa != 'false'
+
+d3d_drivers_path = get_option('d3d-drivers-path')
+if d3d_drivers_path == ''
+ d3d_drivers_path = join_paths(get_option('libdir'), 'd3d')
+endif
+
+with_gallium_st_nine = get_option('gallium-nine')
+if with_gallium_st_nine
+ if not with_gallium_softpipe
+ error('The nine state tracker requires gallium softpipe/llvmpipe.')
+ elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600
+ or with_gallium_r300 or with_gallium_svga or with_gallium_i915)
+ error('The nine state tracker requires at least on non-swrast gallium driver.')
+ endif
+ if not with_dri3
+ error('Using nine with wine requires dri3')
+ endif
+endif
+
+_opencl = get_option('gallium-opencl')
+if _opencl != 'disabled'
+ if not with_gallium
+ error('OpenCL Clover implementation requires at least one gallium driver.')
+ endif
+
+ # TODO: alitvec?
+ dep_clc = dependency('libclc')
+ with_gallium_opencl = true
+ with_opencl_icd = _opencl == 'icd'
+else
+ dep_clc = null_dep
+ with_gallium_opencl = false
+ with_gallium_icd = false