编译 X 驱动程序时,如何在 configure.ac 中测试 XFIXES 的版本?
我正在为 X 编写一个视频设备驱动程序,它需要 XFIXES 扩展提供的一些功能。现在,我非常确定 X Server 的所有目标版本都将至少安装 XFIXES 版本 2,但我真的很想在我的 configure.ac 文件中测试这一点,以在用户尝试时发出警告为非常旧版本的服务器或(由于某种原因)未包含 XFIXES 的服务器编译我的驱动程序。现在我只是这样做:
# 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
AC_CHECK_FUNC
检查库中是否存在特定函数。您之前必须已在该库上运行过AC_CHECK_LIB
才能正常工作。You can use
AC_CHECK_FUNC
to check for the presence of specific functions in a library. You must have previously runAC_CHECK_LIB
on that library for this to work.像这样的事情:
编辑——我现在有点明白问题了。我们将在此基础上构建初始解决方案。
现在我知道我们不能使用 XFIXES_MAJOR (或类似的东西),请使用您关心的结构本身作为测试的结构定义。对于此示例,我假设该结构是 XFixesCursorImage,因为当 XFIXES_MAJOR >= 2 时,它具有一些新组件(例如,名称)。希望定义相同结构的有效服务器标头也将具有这些组件新组件:
包含标头现在应该是标头的服务器版本。这个想法是服务器标头中 XFIXES_MAJOR < 2 将没有该组件并且编译将会失败。如果违反该假设,则该方法也将不起作用。
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.