I’m writing a video device driver for X, and it needs some features provided by the XFIXES Extension. Now, I’m pretty sure that all of my target versions of the X Server will have at least version 2 of XFIXES installed, but I’d really like to test for that in my configure.ac file to warn the user if they try to compile my driver for a really old version of the server or for one in which (for some reason) XFIXES wasn’t included. Right now I’m just doing this:
# Essentially this is just supposed to check if the server currently supports
# V2 or better of the XFIXES protocol, and to define XFIXES if it does.
AC_CHECK_HEADER(X11/extensions/Xfixes.h,
HAVE_XFIXES="yes";
AC_DEFINE([HAVE_XFIXES],[1],[XFixes Proto Found]),,
[#include <X11/Xlib.h>])
# should have a better test for this
if test "x${HAVE_XFIXES}" = "xyes"; then
AC_DEFINE([XFIXES],[1],[XFixes >= 2.0])
fi
Something like this:
EDIT — I now kinda get the problem. We’ll build on the initial solution here.
Now that I know we cannot use XFIXES_MAJOR (or something like it), use the struct definition for a struct you care about itself as the test. For this example I’ll assume the struct is XFixesCursorImage since it has some new components (e.g., name) when XFIXES_MAJOR >= 2. Hopefully, a valid server header defining the same struct will also have those new components:
The include header should now be the server version of the header. The idea is that the server header where XFIXES_MAJOR < 2 will not have that component and compiling it will fail. If that assumption is violated, this approach won’t work either.