AC_DEFINE失败

时间:2015-11-18 17:05:01

标签: autoconf

我正在尝试在autoconf / automake / autoheader ....中自动配置一个主要次要版本和修订版本号的库。

为什么这些符号值会导致以下错误?

# Library Version Master Version DO NOT TOUCH
AC_DEFINE_UNQUOTED([MAJORVERSION], [0], [Library major version])
AC_DEFINE_UNQUOTED([MINORVERSION], [2], [Library minor version])
AC_DEFINE_UNQUOTED([REVISION], [0], [Library revision version])
AC_DEFINE_UNQUOTED([LIB_VER], [["$MAJORVERSION:$MINORVERSION:$REVISION"]], [Library complete version])
m4_esyscmd([echo $LIB_VER > .version])



autoreconf: running: /usr/bin/autoheader --force
configure.ac:30: warning: AC_DEFINE: not an identifier: 
configure.ac:31: warning: AC_DEFINE: not an identifier: 
configure.ac:32: warning: AC_DEFINE: not an identifier: 
configure.ac:33: warning: AC_DEFINE: not an identifier: 
autoheader: warning: missing template: 
autoheader: Use AC_DEFINE([], [], [Description])
autoreconf: /usr/bin/autoheader failed with exit status: 1

在autoconf命令中修复空格,这是Makefile的摘录。

 MAJORVERSION = 
MAKEINFO = ${SHELL} /home/dave/src/libringbuffers-0.2.0/missing makeinfo
MANIFEST_TOOL = :
MINORVERSION = 
MKDIR_P = /bin/mkdir -p
NM = /usr/bin/nm -B
NMEDIT = 
OBJDUMP = objdump
...
PACKAGE_NAME = libringbuffers
PACKAGE_STRING = libringbuffers 0.2.0-2-gd984062
PACKAGE_TARNAME = libringbuffers
PACKAGE_URL = 
PACKAGE_VERSION = 0.2.0-2-gd984062
...
REL_VER = 
REVISION = 
SED = /bin/sed

所以这可能是问题一,但仍然没有存储值......

2 个答案:

答案 0 :(得分:1)

我相信你遇到的问题是由括号前AC_DEFINE_UNQUOTED之后的额外空格引起的。

尝试更换:

AC_DEFINE_UNQUOTED ([MAJORVERSION], [0], [Library major version])
AC_DEFINE_UNQUOTED ([MINORVERSION], [2], [Library minor version])
AC_DEFINE_UNQUOTED ([REVISION], [0], [Library revision version])
AC_DEFINE_UNQUOTED ([LIB_VER], [["$MAJORVERSION:$MINORVERSION:$REVISION"]], [Library complete version])

使用:

AC_DEFINE_UNQUOTED([MAJORVERSION], [0], [Library major version])
AC_DEFINE_UNQUOTED([MINORVERSION], [2], [Library minor version])
AC_DEFINE_UNQUOTED([REVISION], [0], [Library revision version])
AC_DEFINE_UNQUOTED([LIB_VER], [["$MAJORVERSION:$MINORVERSION:$REVISION"]], [Library complete version])

注意:AC_DEFINE_UNQUOTED

后应该有 no 空格

答案 1 :(得分:1)

configure.ac中的以下内容:

AC_DEFUN([AX_DEFINE_SUBST], [
AC_DEFINE_UNQUOTED([$1], [$2], [$3])
AC_SUBST([$1], ['$2'])
])

AX_DEFINE_SUBST([MAJORVERSION], [0], [Library major version])
AX_DEFINE_SUBST([MINORVERSION], [2], [Library minor version])
AX_DEFINE_SUBST([REVISION], [0], [Library revision version])
AC_DEFINE_UNQUOTED([LIB_VER], [["$MAJORVERSION:$MINORVERSION:$REVISION"]], [Library complete version])

AC_CONFIG_HEADERS([config.h])

...

AC_OUTPUT

运行autoreconf && ./configure后,我最终在config.h声明了以下内容:

/* Library complete version */
#define LIB_VER "0:2:0"

/* Library major version */
#define MAJORVERSION 0

/* Library minor version */
#define MINORVERSION 2

/* Library revision version */
#define REVISION 0

注意:AX_DEFINE_SUBST hack取自:How do I combine AC_SUBST and AC_DEFINE?