At the end of a configure run,
config.status
is run,
that creates various files with embedded pieces of information.
It thus propagates the values of various variables
to various files in the build tree
(most notably, Makefile
s and config.h
).
One such propagated value is
the value of the Automake-defined variable $(VERSION)
.
(There is also the Autoconf-defined variable $(PACKAGE_VERSION)
,
but nothing except Automake ought to use it.)
For $(VERSION)
to have a sensible value,
a few lines are needed in configure.ac
.
The recommended code pattern is
AC_INIT AC_CONFIG_SRCDIR([unique-file-in-source-dir]) AC_CONFIG_AUX_DIR([build-aux]) VERSION_NUMBER=`cd $srcdir \ && build-aux/git-version-gen .tarball-version \ | sed -e 's/dirty$/modified/'` gl_INIT_PACKAGE([package], [$VERSION_NUMBER]) AM_INIT_AUTOMAKE([options])
With this code pattern,
the contents of the file .tarball-version and the git status
are considered when configure
is run.
Two older code patterns are deprecated, because they read
the contents of the file .tarball-version and the git status
when autoconf
is run, not when configure
is run.
These older code patterns thus require a longer turnaround cycle
when the maintainer has changed the version number.
The first such old code pattern
is to set the version number directly in configure.ac
:
AC_INIT([package, version]) AC_CONFIG_SRCDIR([unique-file-in-source-dir]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([options])
The second such old code pattern
is to invoke git-version-gen
at autoconf
time:
AC_INIT([package], m4_esyscmd([build-aux/git-version-gen .tarball-version \ | sed -e 's/dirty$/modified/'])]) AC_CONFIG_SRCDIR([unique-file-in-source-dir]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([options])
The macro gl_INIT_PACKAGE
is defined in the Gnulib module package-version
.