+dnl
+dnl DEPRECATED: EGL Platforms configuration
+dnl
+AC_ARG_WITH([egl-platforms],
+ [AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@],
+ [DEPRECATED: use --with-platforms instead@<:@default=auto@:>@])],
+ [with_egl_platforms="$withval"],
+ [with_egl_platforms=auto])
+
+if test "x$with_egl_platforms" = xauto; then
+ with_egl_platforms="x11,surfaceless"
+ if test "x$enable_gbm" = xyes; then
+ with_egl_platforms="$with_egl_platforms,drm"
+ fi
+else
+ AC_MSG_WARN([--with-egl-platforms is deprecated. Use --with-platforms instead.])
+fi
+
+dnl
+dnl Platforms configuration
+dnl
+AC_ARG_WITH([platforms],
+ [AS_HELP_STRING([--with-platforms@<:@=DIRS...@:>@],
+ [comma delimited native platforms libEGL/Vulkan/other supports, e.g.
+ "x11,drm,wayland,surfaceless..." @<:@default=auto@:>@])],
+ [with_platforms="$withval"],
+ [with_platforms=auto])
+
+# Reuse the autodetection rather than duplicating it.
+if test "x$with_platforms" = xauto; then
+ with_platforms=$with_egl_platforms
+fi
+
+PKG_CHECK_MODULES([WAYLAND_SCANNER], [wayland-scanner],
+ WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`,
+ WAYLAND_SCANNER='')
+if test "x$WAYLAND_SCANNER" = x; then
+ AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner], [:])
+fi
+
+# Do per platform setups and checks
+platforms=`IFS=', '; echo $with_platforms`
+for plat in $platforms; do
+ case "$plat" in
+ wayland)
+
+ PKG_CHECK_MODULES([WAYLAND], [wayland-client >= $WAYLAND_REQUIRED wayland-server >= $WAYLAND_REQUIRED])
+
+ if test "x$WAYLAND_SCANNER" = "x:"; then
+ AC_MSG_ERROR([wayland-scanner is needed to compile the wayland platform])
+ fi
+ DEFINES="$DEFINES -DHAVE_WAYLAND_PLATFORM"
+ ;;
+
+ x11)
+ PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb xcb-dri2 >= $XCBDRI2_REQUIRED xcb-xfixes])
+ DEFINES="$DEFINES -DHAVE_X11_PLATFORM"
+ ;;
+
+ drm)
+ test "x$enable_gbm" = "xno" &&
+ AC_MSG_ERROR([EGL platform drm needs gbm])
+ DEFINES="$DEFINES -DHAVE_DRM_PLATFORM"
+ ;;
+
+ surfaceless)
+ DEFINES="$DEFINES -DHAVE_SURFACELESS_PLATFORM"
+ ;;
+
+ android)
+ PKG_CHECK_MODULES([ANDROID], [cutils hardware sync])
+ DEFINES="$DEFINES -DHAVE_ANDROID_PLATFORM"
+ ;;
+
+ *)
+ AC_MSG_ERROR([platform '$plat' does not exist])
+ ;;
+ esac
+
+ case "$plat" in
+ wayland|drm|surfaceless)
+ require_libdrm "Platform $plat"
+ ;;
+ esac
+done
+
+if test "x$enable_glx" != xno; then
+ if ! echo "$platforms" | grep -q 'x11'; then
+ AC_MSG_ERROR([Building GLX without the x11 platform is not supported])
+ fi
+fi
+
+if test x"$enable_dri3" = xyes; then
+ DEFINES="$DEFINES -DHAVE_DRI3"
+
+ dri3_modules="x11-xcb xcb >= $XCB_REQUIRED xcb-dri3 xcb-xfixes xcb-present xcb-sync xshmfence >= $XSHMFENCE_REQUIRED"
+ PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules])
+fi
+
+AM_CONDITIONAL(HAVE_PLATFORM_X11, echo "$platforms" | grep -q 'x11')
+AM_CONDITIONAL(HAVE_PLATFORM_WAYLAND, echo "$platforms" | grep -q 'wayland')
+AM_CONDITIONAL(HAVE_PLATFORM_DRM, echo "$platforms" | grep -q 'drm')
+AM_CONDITIONAL(HAVE_PLATFORM_SURFACELESS, echo "$platforms" | grep -q 'surfaceless')
+AM_CONDITIONAL(HAVE_PLATFORM_ANDROID, echo "$platforms" | grep -q 'android')
+