如何在configure.ac中使用消息变量
if test "$foo" = "yes"; then
AC_MSG_ERROR([this string is being used in WARN as well as ERROR])
else
AC_MSG_WARN([this string is being used in WARN as well as ERROR])
fi
在变量中定义字符串“this string is being using in WARN as well as ERROR”是有意义的,然后在 AC_MSG_WARN 和AC_MSG_ERROR。最好的方法是什么?
除此之外,m4 是否有任何宏可以通过将字符串和 $foo 作为参数来替换整个 if else ?
最佳答案
这应该有效:
msg="this string is being used in WARN as well as ERROR"
if test "$foo" = "yes"; then
AC_MSG_ERROR([$msg])
else
AC_MSG_WARN([$msg])
fi
In addition to that, does m4 has any macro which can replace this entire if else by taking string and $foo as argument ?
如果你写一个,它就会的。 :-)。 if-else 不在 m4 中,而是在 m4(configure
shell 脚本)的输出中。像这样的东西:
AC_DEFUN([AX_TEST_FOO], [
pushdef([MSG],$1)
pushdef([FOO],$2)
AS_IF([test $FOO = yes], [AC_MSG_ERROR([$MSG])], [AC_MSG_WARN([$MSG])])
popdef([FOO])
popdef([MSG])
])
调用方式如下:
AX_TEST_FOO(["this string is being used in WARN as well as ERROR"], [$foo])
应该很接近。我没试过。
关于autotools - 如何在 autoconf :configure. ac 中使用字符串变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15541534/