+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 = []
+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 = []
+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 _omx == 'true'
+ error('OMX state tracker can only be built on unix-like OSes.')
+ else
+ _omx = 'false'
+ endif
+elif not (with_platform_x11 or with_platform_drm)
+ if _omx == 'true'
+ error('OMX state tracker requires X11 or drm platform support.')
+ else
+ _omx = 'false'
+ endif
+elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
+ if _omx == 'true'
+ error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
+ else
+ _omx = 'false'
+ endif
+elif _omx == 'auto'
+ _omx = 'true'
+endif
+with_gallium_omx = _omx == 'true'
+dep_omx = []
+if with_gallium_omx
+ dep_omx = dependency('libomxil-bellagio')
+endif
+
+omx_drivers_path = get_option('omx-libs-path')
+if with_gallium_omx
+ # 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'