+# We require OpenGL for OpenGL ES
+if (with_gles1 or with_gles2) and not with_opengl
+ error('building OpenGL ES without OpenGL is not supported.')
+endif
+
+with_dri = false
+with_dri_i915 = false
+with_dri_i965 = false
+with_dri_r100 = false
+with_dri_r200 = false
+with_dri_nouveau = false
+with_dri_swrast = false
+_drivers = get_option('dri-drivers')
+if _drivers != ''
+ _split = _drivers.split(',')
+ with_dri_i915 = _split.contains('i915')
+ with_dri_i965 = _split.contains('i965')
+ with_dri_r100 = _split.contains('r100')
+ with_dri_r200 = _split.contains('r200')
+ with_dri_nouveau = _split.contains('nouveau')
+ with_dri_swrast = _split.contains('swrast')
+ with_dri = true
+endif
+
+with_gallium = false
+with_gallium_pl111 = false
+with_gallium_radeonsi = 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
+_drivers = get_option('gallium-drivers')
+if _drivers != ''
+ _split = _drivers.split(',')
+ with_gallium_pl111 = _split.contains('pl111')
+ with_gallium_radeonsi = _split.contains('radeonsi')
+ 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 = true
+ with_dri = true
+endif
+
+if not (with_dri or with_gallium)
+ with_gles1 = false
+ with_gles2 = false
+ with_opengl = false
+ with_any_opengl = false
+ with_shared_glapi = false
+endif
+
+if with_dri_swrast and with_gallium_softpipe
+ error('Only one swrast provider can be built')
+endif
+if with_gallium_imx and not with_gallium_etnaviv
+ error('IMX driver requires etnaviv driver')
+endif
+
+dep_libdrm_intel = []
+if with_dri_i915
+ dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
+endif
+
+# TODO: other OSes
+with_dri_platform = 'drm'
+
+# TODO: android platform