daemondave
daemondave

Reputation: 305

AC_DEFINE failing

I am trying to configure a library with major minor and revision version numbers automagically inside autoconf/automake/autoheader....

Why do these symbol values cause following errors?

# 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

Post fixing for spaces in the autoconf commands, this is the Makefile excerpt.

 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

So that might have been problem one, but still not storing values...

Upvotes: 2

Views: 2207

Answers (2)

mkrufky
mkrufky

Reputation: 3388

With the following in 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

After running autoreconf && ./configure, I end up with the following declared in 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

note: AX_DEFINE_SUBST hack taken from: How do I combine AC_SUBST and AC_DEFINE?

Upvotes: 1

mkrufky
mkrufky

Reputation: 3388

I believe the problem you're having is caused by the extra space after AC_DEFINE_UNQUOTED before the parenthesis.

Try replacing:

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])

with:

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])

Note: there should be no space after AC_DEFINE_UNQUOTED

Upvotes: 1

Related Questions