Hi,

It has been discussed recently that the way the VERSION is set with automake is suboptimal when the VERSION is changing frequently [1]. The problem is basically that autoconf has to be re-run every time the VERSION is updated, which is not convenient if the VERSION is updated, e.g., at every commit to the RVS.

I've played around with a work-around inspired by the git-version-gen script in gnulib [2]. Please find a revised version of amhello using the idea attached. The idea is, as suggested by by Ralf Wildenhues, to keep the version information in a separate file `.version' [3]. Other files/targets can then depend on `.version' and propagate the version information as appropriate. `.version' is updated from the output of a script `gen-version'; here only a wrapper around `date' but could in principle be anything from `git describe', `svnversion' to home brewed scripts extracting the version from, e.g., ChangeLog. When building from a tarball, there exists a file `.tarball-version' and when this file is present `.version' will not be updated from the `gen-version' script. That is because it is desired that the version is set when the maintainer issues `make distcheck' and not at a later point when some user builds the package, and also in many situations `gen-version' is impossible to run outside the RVS environment, e.g., when the version is set by `svnversion'.

Here, the version is propagated to two places: 1) To the hello program, which is done by generating a short source file `version.c'. This implies when the version changes, only `version.o' needs to be re-compiled and version information can be linked into the programs. 2) The version is also propagated into the Makefile and in particular so the $(distdir) is set accurately. This is done by overriding the $(VERSION) variable, and this is done in a file `.version.mk' that is included into the Makefile. The file `.version.mk' in turn is generated from `.version' and since $(VERSION) is set in a separate file it can be updated without re-generating the entire Makefile via config.status.

I chose to have rules for `.version' and `.version.mk' in all Makefiles and since they are the same everywhere, I located them in a file `version.am' that is included at automake time. The attached tarball is obviously not created with `make dist' but what a developer would check out from a RVS.

Thoughts or any feedback are very welcome.

Cheers,
Peter

[1]  http://www.mail-archive.com/automake@gnu.org/msg15075.html
[2] http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=build-aux/git-version-gen
[3]  http://www.mail-archive.com/automake@gnu.org/msg15121.html

Attachment: amhello.tar.gz
Description: GNU Zip compressed data

Reply via email to