if [ "${OPENGL}" = no ]; then
  OPENGL_SUPPORT="no"
else
  OPENGL_SUPPORT="yes"
fi

if [ "${OPENGLES}" = no ]; then
  OPENGLES_SUPPORT="no"
else
  OPENGLES_SUPPORT="yes"
fi

get_graphicdrivers() {

  # set defaults
  GALLIUM_DRIVERS=""
  DRI_DRIVERS=""
  XORG_DRIVERS=""
  LLVM_SUPPORT="no"
  COMPOSITE_SUPPORT="no"
  VDPAU_SUPPORT="no"
  VAAPI_SUPPORT="no"
  V4L2_SUPPORT="no"

  if [ "${GRAPHIC_DRIVERS}" = "all" ]; then
    GRAPHIC_DRIVERS="i915 i965 r200 r300 r600 radeonsi nvidia nvidia-legacy vmware virtio vc4"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "etnaviv"; then
    GALLIUM_DRIVERS+=" etnaviv imx"
    V4L2_SUPPORT="yes"
    VAAPI_SUPPORT="no"
    VDPAU_SUPPORT="no"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "freedreno"; then
    GALLIUM_DRIVERS+=" freedreno"
    V4L2_SUPPORT="yes"
    VAAPI_SUPPORT="no"
    VDPAU_SUPPORT="no"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "i915"; then
    DRI_DRIVERS+=" i915"
    XORG_DRIVERS+=" intel"
    COMPOSITE_SUPPORT="yes"
    VAAPI_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "i965"; then
    DRI_DRIVERS+=" i965"
    XORG_DRIVERS+=" intel"
    COMPOSITE_SUPPORT="yes"
    VAAPI_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "lima"; then
    GALLIUM_DRIVERS+=" kmsro lima"
    V4L2_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "nvidia"; then
    XORG_DRIVERS+=" nvidia"
    VDPAU_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "nvidia-legacy"; then
    XORG_DRIVERS+=" nvidia-legacy"
    VDPAU_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "panfrost"; then
    GALLIUM_DRIVERS+=" kmsro panfrost"
    V4L2_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "r200"; then
    DRI_DRIVERS+=" r200"
    XORG_DRIVERS+=" ati"
    COMPOSITE_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "r300"; then
    GALLIUM_DRIVERS+=" r300"
    XORG_DRIVERS+=" ati"
    LLVM_SUPPORT="yes"
    COMPOSITE_SUPPORT="yes"
    VDPAU_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "r600"; then
    GALLIUM_DRIVERS+=" r600"
    XORG_DRIVERS+=" ati"
    LLVM_SUPPORT="yes"
    COMPOSITE_SUPPORT="yes"
    VDPAU_SUPPORT="yes"
    VAAPI_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "radeonsi"; then
    GALLIUM_DRIVERS+=" radeonsi"
    XORG_DRIVERS+=" ati amdgpu"
    LLVM_SUPPORT="yes"
    COMPOSITE_SUPPORT="yes"
    VDPAU_SUPPORT="yes"
    VAAPI_SUPPORT="yes"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "vc4"; then
    GALLIUM_DRIVERS+=" vc4 v3d kmsro"
    V4L2_SUPPORT="yes"
    VAAPI_SUPPORT="no"
    VDPAU_SUPPORT="no"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "virtio"; then
    GALLIUM_DRIVERS+=" virgl"
  fi

  if listcontains "${GRAPHIC_DRIVERS}" "vmware"; then
    GALLIUM_DRIVERS+=" svga"
    XORG_DRIVERS+=" vmware"
    COMPOSITE_SUPPORT="yes"
  fi

  # remove duplicate entries
  GALLIUM_DRIVERS="$(echo ${GALLIUM_DRIVERS} | xargs -n1 | sort -u | xargs)"
  XORG_DRIVERS="$(echo ${XORG_DRIVERS} | xargs -n1 | sort -u | xargs)"
  DRI_DRIVERS="$(echo ${DRI_DRIVERS} | xargs -n1 | sort -u | xargs)"
}
