【问题标题】:bison in autoconf can not prompt AC_ERRORautoconf中的bison不能提示AC_ERROR
【发布时间】:2013-05-29 19:34:49
【问题描述】:

我的 configure.ac 是:

AC_PREREQ(2.69)
AC_INIT([mkbib], [2.1], [bnrj.rudra@yahoo.com])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.9.6 dist-bzip2 subdir-objects foreign])

# Checks for programs.
AC_PROG_CC

AC_PROG_YACC
#if test x"$YACC" != x"yes"; then
#  AC_MSG_ERROR([Please install bison before installing.])
#fi
AC_PROG_LEX
if test "x$LEX" != xflex; then
  AC_MSG_ERROR([Please install flex before installing.])
fi

AC_CONFIG_MACRO_DIR([m4])
GNOME_DOC_INIT 

# Compiling sources with per-target flags requires AM_PROG_CC_C_O
AM_PROG_CC_C_O
AC_PROG_INSTALL

#AC_PROG_LIBTOOL
PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4 >= 2.26)
AC_SUBST(LIBSOUP_CFLAGS)
AC_SUBST(LIBSOUP_LIBS)

AM_PATH_GTK_3_0([3.4.0],,AC_MSG_ERROR([Gtk+ 3.0.0 or higher required.]))

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
        Makefile
        help/Makefile
])
AC_OUTPUT

问题是,在运行从该文件构建的 ./configure 时,请检查 YACC 的存在(如野牛,当 AC_PROG_YACC 后面的 3 行时,它 显示一元错误),但一旦检测到错误就不会退出。作为, 运行,它显示:

checking for bison... no
checking for byacc... no
.........................
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating help/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands

那么,我怎样才能让 configure.ac 停止丢失野牛并做一些 AC_MSG_ERROR 而不是创建一个不会被编译的 Makefile?

编辑:@ldav1s,比较字符串“bison -y”并不通用,因为 AC_PROG_YACC 同时检查 bison/byacc。所以,我在想是否可以在显示“否”时放置 AC_MSG_ERROR。 所以寻找类似的东西:

AC_PROG_YACC
if test  "x$YACC" = "xno"; then
  AC_MSG_ERROR([Please install bison before installing.])
fi

所以,我是

【问题讨论】:

  • 我知道AC_PROG_YACC 测试其他yacc 替换程序。你说你想要bison。所以我测试了bison

标签: bison autoconf


【解决方案1】:

这是经过测试和检查的。当找不到 bison/byacc/yacc 时它会停止。

AC_PROG_YACC
if test x"$YACC" = "xyacc"; then
  AC_CHECK_PROG([YACC_EXISTS], [yacc], [yes], [no])
  if test x"$YACC_EXISTS" != xyes; then
    AC_MSG_ERROR([[bison/byacc/yacc not found.
          Please install bison]])
  fi
fi

这是为了线程的完整性。

【讨论】:

    【解决方案2】:

    这个问题的存在是因为autoconf sets LEX to ':' if it can't find a lex,因为它假定生成的文件将被分发(通常使用make dist 制作的压缩包就是这种情况,但如果您直接生成压缩包则不会)

    所有这些其他解决方案似乎都假定$YACC'yacc'(如果存在)。也许是更通用的解决方案:

    AC_PROG_YACC
    AC_PATH_PROG(YACC_INST, $YACC)
    if test -z "$YACC_INST"; then
       AC_MSG_ERROR([yacc not found])
    fi
    

    【讨论】:

      【解决方案3】:

      通过修复注释掉的代码,并添加更多代码:

      my_YACC=$YACC
      AC_PROG_YACC
      if test -z "$my_YACC" -a x"$YACC" = x"yacc"; then
        AC_MSG_ERROR([Please install bison/byacc before installing.])
      fi
      

      【讨论】:

        【解决方案4】:

        啊....对不起!解决了。​​

        AC_PROG_YACC
        if test  "x$YACC" = "xno"; then
            AC_MSG_ERROR([Please install bison before installing.])
        fi
        

        【讨论】:

        • -1:不起作用。如果 bison/byacc 测试失败,AC_PROG_YACCYACC 设置为 yacc
        • 真;可能这没有问题;仅当没有 YACC 风格可用时,configure 才会显示错误。您对 configure.ac 的理由/期望是什么?
        • YACC 永远不会被设置为 no(除非用户设置它)。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-11-03
        • 1970-01-01
        • 1970-01-01
        • 2012-06-28
        • 1970-01-01
        • 1970-01-01
        • 2015-07-16
        相关资源
        最近更新 更多