+with_gallium = false
+with_gallium_pl111 = false
+with_gallium_radeonsi = false
+with_gallium_r300 = false
+with_gallium_r600 = false
+with_gallium_nouveau = false
+with_gallium_freedreno = false
+with_gallium_softpipe = false
+with_gallium_vc4 = false
+with_gallium_vc5 = false
+with_gallium_etnaviv = false
+with_gallium_imx = false
+with_gallium_i915 = false
+with_gallium_svga = false
+with_gallium_virgl = false
+_drivers = get_option('gallium-drivers')
+if _drivers == 'auto'
+ if not ['darwin', 'windows'].contains(host_machine.system())
+ # TODO: PPC, Sparc
+ if ['x86', 'x86_64'].contains(host_machine.cpu_family())
+ _drivers = 'r300,r600,radeonsi,nouveau,virgl,svga,swrast'
+ elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
+ _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,virgl,svga,swrast'
+ else
+ error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
+ endif
+ else
+ error('Unknown OS. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
+ endif
+endif
+if _drivers != ''
+ _split = _drivers.split(',')
+ with_gallium_pl111 = _split.contains('pl111')
+ with_gallium_radeonsi = _split.contains('radeonsi')
+ with_gallium_r300 = _split.contains('r300')
+ with_gallium_r600 = _split.contains('r600')
+ with_gallium_nouveau = _split.contains('nouveau')
+ with_gallium_freedreno = _split.contains('freedreno')
+ with_gallium_softpipe = _split.contains('swrast')
+ with_gallium_vc4 = _split.contains('vc4')
+ with_gallium_vc5 = _split.contains('vc5')
+ with_gallium_etnaviv = _split.contains('etnaviv')
+ with_gallium_imx = _split.contains('imx')
+ with_gallium_i915 = _split.contains('i915')
+ with_gallium_svga = _split.contains('svga')
+ with_gallium_virgl = _split.contains('virgl')
+ with_gallium = true
+endif
+
+with_intel_vk = false
+with_amd_vk = false
+with_any_vk = false
+_vulkan_drivers = get_option('vulkan-drivers')
+if _vulkan_drivers == 'auto'
+ if not ['darwin', 'windows'].contains(host_machine.system())
+ if host_machine.cpu_family().startswith('x86')
+ _vulkan_drivers = 'amd,intel'
+ else
+ error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
+ endif
+ else
+ # No vulkan driver supports windows or macOS currently
+ _vulkan_drivers = ''
+ endif
+endif
+if _vulkan_drivers != ''
+ _split = _vulkan_drivers.split(',')
+ with_intel_vk = _split.contains('intel')
+ with_amd_vk = _split.contains('amd')
+ with_any_vk = with_amd_vk or with_intel_vk
+endif
+
+if with_dri_swrast and with_gallium_softpipe
+ error('Only one swrast provider can be built')
+endif
+if with_dri_i915 and with_gallium_i915
+ error('Only one i915 provider can be built')
+endif
+if with_gallium_imx and not with_gallium_etnaviv
+ error('IMX driver requires etnaviv driver')