开发者

How to pass and use arguments in ./configure?

I would like to be able pass arguments to ./configure script, so开发者_JAVA技巧 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?


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.

AC_ARG_ENABLE(foo, "used to turn on the NDEBUG flag",
  [ AC_DEFINE(NDEBUG) ]
)


You can use AH_VERBATIM in order to add extra data to your config.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 the config.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:

AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
#ifdef NDEBUG
#/**/undef/**/ NDEBUG
#endif])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜