AC_CACHE_CHECK 应该如何重置?
AC_CACHE_CHECK 应该如何重置?
在 autoconf 中我正在检查标头。我添加了一些逻辑,以便更努力地在 std 文件夹中查找可能不在默认包含路径中的头文件。我这样做的方法是首先尝试查找带有内置 AC_CHECK_HEADER 的头文件。如果找不到标头,我会修改 CPPFLAGS 并重试。
问题在于 autoconf 的缓存。我想强制检查(或绕过缓存检查)。如果我不强制检查,无论 autoconf 是否找到标头,它都会提取在第一次检查中找到的内容,呃。
谢谢, 陈兹
How should AC_CACHE_CHECK be reset?
In autoconf I am checking for headers. I've added some logic to try a little harder to find header files in std folders that might not be in the default include path. The way I do this is first attempt to find a header file with the built-in AC_CHECK_HEADER. If header is not found, I modify the CPPFLAGS and try again.
The problem with this is autoconf's caching. I want to force the check (or bypass the cache check.) If I do not force it, whether autoconf finds the header or not, it will pull what it found in the first check, ugh.
Thanks,
Chenz
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取消设置缓存变量,例如ac_cv_header_syslog_h。您可以检查 config.log 来了解您感兴趣的缓存变量的准确拼写。不幸的是,无法移植地取消设置 shell 变量。 Autoconf 使用的内部解决方法是使用
$as_unset
,如果支持的话,它会扩展为unset
。所以你可以写:不过,这应该适用于当今最合理的系统。
更好、更直接的解决方案可能是为第一轮检查正确设置 CPPFLAGS 。正如您所注意到的,您正在尝试的内容并没有得到真正的支持。
Unset the cache variable, such as
ac_cv_header_syslog_h
. You can checkconfig.log
for the exact spelling of the cache variable you are interested in. Unfortunately, unsetting a shell variable cannot be done portably. The internal workaround that Autoconf uses is using$as_unset
, which expands tounset
if it's supported. So you could write:This should work in most reasonable systems nowadays, though.
A better and more straightforward solution might be to just set
CPPFLAGS
correctly for the first round of checks. As you noticed, what you are trying isn't really supported.我已经实现了一个小宏,它可以完成这项工作(至少对我来说)。通过微小的更改,它可以用于使其他缓存变量无效:
和用法(在此循环中 $1 = 某个库(例如“netpbm”),$2 = 标头(例如“pbm.h ppm.h”),$3 = 位置(例如“/usr/include /usr/local/include”)):
I have implemented a small macro, that does the job (at least for me). With minor changes it can be used to invalidate other cache variables:
and usage (in this loop $1 = some library (e.g. "netpbm"), $2 = headers (e.g. "pbm.h ppm.h"), $3 = locations (e.g. "/usr/include /usr/local/include")):