如何在./configure中传递和使用参数?
我希望能够将参数传递给 ./configure
脚本,以便它将使用的 NDEBUG 添加到我生成的头文件中。我怎样才能做到这一点?我的 configure
脚本是从 configure.ac
生成的。
我已经有了一个很好的答案,但看来我的问题是错误的。该选项必须删除此 NDEBUG,因为默认情况下我希望关闭断言。没有 AC_UNDEFINE,所以我需要使用一些技巧:定义 ASSERT_ON
,这会关闭 NDEBUG
。有没有更简单、更好的方法呢?
I would like to be able pass arguments to ./configure
script, so it would add NDEBUG used by to my generated header file. How can I do that? My configure
script is generated from configure.ac
.
I already one great answer, but it seems that I my question is wrong. The option would have to remove this NDEBUG
, because by default I would like to have assertions turned off. There is no AC_UNDEFINE, so I need to use some trick: define ASSERT_ON
, which would turn off NDEBUG
. Is there any easier, better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当有人将 --enable-foo 添加到您的命令行选项时,您需要在 configure.ac 文件中使用 AC_ARG_ENABLE() 宏来触发操作。
You'll want to use the AC_ARG_ENABLE() macro in your configure.ac file to trigger an action when someone adds --enable-foo to your command line options.
您可以使用
AH_VERBATIM
向config.h.in
添加额外数据(以及config.h
文件)。问题是,在从模板生成 config.h 文件时,autoconf 将注释掉任何看起来像 #undef 语句的内容。
有一个预处理器技巧可以避免这种情况:使用
#/**/undef/**/
。 C 预处理器将首先删除注释,但 autoconf 不会将其视为#undef
语句。回顾一下,为了强制
NDEBUG
未定义:You can use
AH_VERBATIM
in order to add extra data to yourconfig.h.in
(and thus,config.h
file).The thing is,
autoconf
is going to comment out anything that looks like a#undef
statement when producing theconfig.h
file out of the template.There is a preprocessor trick to avoid that: use
#/**/undef/**/
. The C preprocessor is going to strip the comments first, but autoconf will not see that as a#undef
statement.To recap, in order to enforce
NDEBUG
being undefined: