autoconf AS_IF没有执行正确的分支 [英] autoconf AS_IF doesn't execute correct branch
问题描述
在autoconf脚本中,尤其是在 AS_IF
中,我有点神秘.
I'm having a bit of a mystery in a autoconf script, specifically AS_IF
.
以下是相关代码:
AC_CHECK_FUNCS([eventfd], [AC_DEFINE([NN_HAVE_EVENTFD])])
AC_CHECK_FUNCS([pipe], [AC_DEFINE([NN_HAVE_PIPE])])
AC_CHECK_FUNCS([pipe2], [
AC_DEFINE([NN_HAVE_PIPE2])
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])
AC_SEARCH_LIBS([socketpair], [], [AC_DEFINE([NN_HAVE_SOCKETPAIR])])
即检查它们的存在.它们可以正常工作并定义正确的符号.在这种情况下,仅定义了 NN_HAVE_PIPE
和 NN_HAVE_SOCKETPAIR
,这是正确的,因为这是HP-UX系统.
i.e. checking for their existance. These work correctly and define the correct symbols. In this case, only NN_HAVE_PIPE
and NN_HAVE_SOCKETPAIR
gets defined, which is correct as this is a HP-UX system.
现在到神秘的部分.稍后在configure.ac中,有条件地引用这些符号:
Now to the mystery part. Later in the configure.ac, there's a conditional referring to these symbols:
echo "ac_cv_func_eventfd: $ac_cv_func_eventfd"
AS_IF([test x"$ac_cv_func_eventfd"=xyes], [
AC_DEFINE([NN_USE_EVENTFD])], [
AS_IF([test x"$ac_cv_func_pipe"=xyes], [
AC_DEFINE([NN_USE_PIPE])], [
AS_IF([test x"$ac_cv_func_socketpair"=xyes], [
AC_DEFINE([NN_USE_SOCKETPAIR])], [
AC_MSG_ERROR([No signaling supported])
])
])
])
即使 ac_cv_func_eventfd
的值是 no
(我添加了回显行以确保),还是定义了 NN_USE_EVENTFD
!
Even though ac_cv_func_eventfd
has value no
(I added the echo line to make sure), NN_USE_EVENTFD
gets defined anyway!
由于 AS_IF
宏的定义如下:
AS_IF (test1, [run-if-true1], ..., [run-if-false])
对我来说,代码似乎很正确,不是吗?有没有人可以阐明这种行为?
To me, the code seems quite correct, no? Is there anyone that can shed some light on this behavior?
Autoconf版本为2.67.操作系统是HP-UX 11.31 ia64.
Autoconf version is 2.67. The OS is HP-UX 11.31 ia64.
推荐答案
不太正确.您必须从以下位置修复 AS_IF
测试:
Not quite correct. You must fix your AS_IF
test from:
test x"$ac_cv_func_eventfd"=xyes
到
test x"$ac_cv_func_eventfd" = xyes
请注意在 =
周围插入空格.其他 AS_IF
s中的其他测试也是如此.
Note the insertion of spaces around the =
. Same goes for the other tests in the other AS_IF
s.
要验证这一点,您可以尝试在命令行上看到它:
To verify this you can try seeing this at the command line:
if test x"no"=xyes; then echo "yes"; else echo "no"; fi
vs.
if test x"no" = xyes; then echo "yes"; else echo "no"; fi
这篇关于autoconf AS_IF没有执行正确的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!