+with_libunwind = get_option('libunwind')
+with_asm = get_option('asm')
+with_llvm = get_option('llvm')
+with_osmesa = get_option('osmesa')
+if get_option('texture-float')
+ pre_args += '-DTEXTURE_FLOAT_ENABLED'
+ message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.')
+endif
+
+# XXX: yeah, do these
+with_appledri = false
+with_windowsdri = false
+
+dri_drivers_path = get_option('dri-drivers-path')
+if dri_drivers_path == ''
+ dri_drivers_path = join_paths(get_option('libdir'), 'dri')
+endif
+
+with_gles1 = get_option('gles1')
+with_gles2 = get_option('gles2')
+with_opengl = get_option('opengl')
+with_any_opengl = with_opengl or with_gles1 or with_gles2
+# Only build shared_glapi if at least one OpenGL API is enabled
+with_shared_glapi = get_option('shared-glapi') and with_any_opengl
+
+
+# shared-glapi is required if at least two OpenGL APIs are being built
+if not with_shared_glapi
+ if ((with_gles1 and with_gles2) or (with_gles1 and with_opengl)
+ or (with_gles2 and with_opengl))
+ error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
+ endif
+endif
+
+# 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 == 'auto'
+ # TODO: PPC, Sparc
+ if not ['darwin', 'windows'].contains(host_machine.system())
+ if ['x86', 'x86_64'].contains(host_machine.cpu_family())
+ _drivers = 'i915,i965,r100,r200,nouveau'
+ else
+ error('Unknown architecture. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
+ endif
+ else
+ error('Unknown OS. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
+ endif
+endif
+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 == 'auto'
+ if not ['darwin', 'windows'].contains(host_machine.system())
+ # TODO: PPC, Sparc
+ if ['x86', 'x86_64'].contains(host_machine.cpu_family())
+ _drivers = 'radeonsi,nouveau,swrast'
+ elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
+ _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,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_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
+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_gallium_imx and not with_gallium_etnaviv
+ error('IMX driver requires etnaviv driver')
+endif