+if test "${window_system}" = "x11"; then
+ AC_MSG_CHECKING(X11 version 6)
+ AC_TRY_LINK([#include <X11/Xlib.h>],
+[#if XlibSpecificationRelease < 6
+fail;
+#endif
+], [AC_MSG_RESULT(6 or newer)
+ AC_DEFINE(HAVE_X11R6)],
+ [AC_MSG_RESULT(before 6)])
+fi
+
+if test "${window_system}" = "x11"; then
+ AC_MSG_CHECKING(X11 version 5)
+ AC_TRY_LINK([#include <X11/Xlib.h>],
+[#if XlibSpecificationRelease < 5
+fail;
+#endif
+], [AC_MSG_RESULT(5 or newer)
+ HAVE_X11R5=yes
+ AC_DEFINE(HAVE_X11R5)],
+ [
+ HAVE_X11R5=no
+ AC_MSG_RESULT(before 5)])
+fi
+
+if test x"${USE_X_TOOLKIT}" = xmaybe; then
+ if test x"${HAVE_X11R5}" = xyes; then
+ AC_MSG_CHECKING(X11 version 5 with Xaw)
+ AC_TRY_LINK([
+ #include <X11/Intrinsic.h>
+ #include <X11/Xaw/Simple.h>],
+ [],
+ [AC_MSG_RESULT(5 or newer, with Xaw; use toolkit by default)
+ USE_X_TOOLKIT=LUCID],
+ [AC_MSG_RESULT(before 5 or no Xaw; do not use toolkit by default)
+ USE_X_TOOLKIT=none])
+ else
+ USE_X_TOOLKIT=none
+ fi
+fi
+
+X_TOOLKIT_TYPE=$USE_X_TOOLKIT
+