Ale*_*lex 4 automake autoconf autotools
我可能需要添加很多AC_ARG_ENABLE,目前我正在使用下面的语法,这是我唯一工作的语法,但我想知道是否已经有一些m4宏用于我正在使用的简单的action-if-given测试(我做了一些搜索,但什么也没找到)或更好的更清晰的语法。
我见过一些空的例子,[]但无法让它工作,我需要创建一个新的宏吗?
AC_ARG_ENABLE([welcome],
AS_HELP_STRING([--enable-welcome], [Enable welcome route example @<:@default=yes@:>@]),
[case "${enableval}" in
yes) enable_welcome=true ;;
no) enable_welcome=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-welcome]) ;;
esac],[enable_welcome=true])
AM_CONDITIONAL([ENABLE_WELCOME], [test x$enable_welcome = xtrue])
Run Code Online (Sandbox Code Playgroud)
这是我如何使用它的Makefile.am
if ENABLE_WELCOME
...
endif
Run Code Online (Sandbox Code Playgroud)
我只是AC_ARG_ENABLE将选项处理本身分开,将选项处理逻辑分开,并保持configure.ac易于阅读:
AC_ARG_ENABLE([welcome],
[AS_HELP_STRING([--enable-welcome], [... description ... ])],,
[enable_welcome=yes])
# i.e., omit '[<action-if-given>]', still sets '$enable_welcome'
enable_welcome=`echo $enable_welcome` # strip whitespace trick.
case $enable_welcome in
yes | no) ;; # only acceptable options.
*) AC_MSG_ERROR([unknown option '$enable_welcome' for --enable-welcome]) ;;
esac
# ... other options that may affect $enable_welcome value ...
AM_CONDITIONAL([ENABLE_WELCOME], [test x$enable_welcome = xyes])
Run Code Online (Sandbox Code Playgroud)
当然,autoconf 提倡使用可移植的 shell 结构,例如AS_CASE、AS_IF等。这可能是“正确的事情”,但我发现语法很烦人。如果我受到 shell 限制的困扰,我想我将不得不考虑它们。
如果此构造频繁出现,您可能需要一些最少的概念yes/no来定义自己的函数。但是您应该能够找到大量有关如何访问函数参数和返回值的示例。AC_DEFUNm4
| 归档时间: |
|
| 查看次数: |
3148 次 |
| 最近记录: |