【问题标题】:autoconf: error: possibly undefined macro: AC_LIBOBJautoconf:错误:可能未定义的宏:AC_LIBOBJ
【发布时间】:2014-04-19 12:54:18
【问题描述】:

给定以下 autoconf sn-p:

if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes" -a x"$ac_cv_type_struct_addrinfo" = x"yes"; then
    # Tru64 UNIX has getaddrinfo() but has it renamed in libc as
    # something else so we must include <netdb.h> to get the
    # redefinition.
    AC_CHECK_FUNCS(getaddrinfo, ,
            [AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
            AC_TRY_LINK([#include <sys/types.h>
            #include <sys/socket.h>
            #include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
                    [AC_MSG_RESULT([yes])
                    AC_DEFINE(HAVE_GETADDRINFO, 1,
                            [Define to 1 if you have the "getaddrinfo" function and required types.])],
                    [AC_MSG_RESULT([no])
                    AC_LIBOBJ([getaddrinfo])])])
else
    AC_LIBOBJ([getaddrinfo])
fi

在该项目中运行autoconfautoreconf -fi 时,出现错误:

configure.ac:529: error: possibly undefined macro: AC_LIBOBJ

它指向第一个出现的AC_LIBOBJ

改为运行以下序列:

aclocal
autoreconf

问题在于,在这个特定的项目中,配置脚本应该命名为 configure.sh(并使用包装器调用),所以我必须改用这个序列:

autoconf -o configure.sh
autoreconf

总是会产生上述错误。

这是autoconf-2.69 加上我设置了以下(相关)选项:

AM_INIT_AUTOMAKE([subdir-objects tar-ustar foreign])
AC_CONFIG_LIBOBJ_DIR([lib])

我很可能会在未来某个时候将整个检测替换为 gnulib 中包含的检测,但目前我希望保持原样。

【问题讨论】:

  • 为什么要命名为.sh?这是任意且具有误导性的,因为configure.ac 不是有效的shell 脚本。问题是你告诉 autoconf 你错命名的 configure.ac 是什么,但没有告诉 aclocal 相同的信息。
  • 不应将 configure.ac 命名为 configure.sh,但结果是:我想要/需要 configure.sh 脚本而不是配置脚本。 autoconf 的结果(配置脚本本身)是一个有效的 shell 脚本。但正如我所写,问题开始得更早,例如在运行 autoreconf -fi 时。
  • 对不起,我看错了你的描述。为什么不能手动调用aclocal/autoconf/automake?我相信你必须用“-o”告诉autoconf输出的明确名称,因为automake会跟踪它的依赖关系(configure.ac)并在需要时重新生成它。你不能简单地让configure.sh调用configure吗?
  • 好的,我更新了描述。我的问题的重点是:我想知道为什么会发生这个错误。即使在产生该错误之前将 AC_LIBOBJ([something]) 放在单独的行上,我也不明白为什么。

标签: autoconf


【解决方案1】:
apt-get install pkg-config

帮我解决问题。

【讨论】:

  • 我无法理解为什么这对我有帮助,但确实如此,即使在 mingw-w64 上也是如此。
  • 此修复适用于构建 simple-mtpfs 时的 Devuan ceres。
【解决方案2】:

问题似乎是configure.ac 中的以下代码:

# define the directory for replacement function since AC_LIBOBJ does not
# officially support subdirs and fails with automake
AC_CONFIG_LIBOBJ_DIR([lib])

我真正应该使用 autoconf 注释的地方:

dnl define the directory for replacement function since AC_LIBOBJ does not
dnl officially support subdirs and fails with automake
AC_CONFIG_LIBOBJ_DIR([lib])

【讨论】:

    【解决方案3】:

    这通常是因为不同的宏以不正确的方式展开。我建议你做两件事:使用AS_IF 而不是if .. then .. else 语句,并避免使用多个嵌套宏。

    只需将结果变量设置为是或否,然后使用单个AC_MSG_RESULT;而不是调用AC_LIBOBJ 两次,只需调用一次检查该变量即可。

    【讨论】:

    • 嗯,这并没有解决我的问题,但它为我指明了正确的方向。
    猜你喜欢
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    • 2015-04-18
    • 1970-01-01
    • 1970-01-01
    • 2019-05-07
    • 2012-02-07
    相关资源
    最近更新 更多