The manual provides a possible solution:
The arguments of AC_INIT must be static, i.e., there should not be any
shell computation, quotes, or newlines, but they can be computed by
M4... It is permissible to use m4_esyscmd or m4_esyscmd_s for
computing a version string that changes with every commit to a version
control system (in fact, Autoconf does just that, for all builds of
the development tree made between releases).
Since autoconf
itself uses this in its own configure.ac
:
AC_INIT([GNU Autoconf],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[bug-autoconf@gnu.org])
you need to replace this with a system command or shell script of your own to get a version string. e.g., a top-level file called .foo-version
with "MAJOR.MINOR
", and borrowing from git-version-gen
, something like: m4_esyscmd([tr -d '\n' < ../.foo-version])
I suppose you could use the same command in the top-level package, replacing ../
with ./
of course. Since m4 is invoking a system command, you're free to get the version string any way you prefer.