Use git describe to populate autoconf's VERSION.
authorEtienne Dechamps <etienne@edechamps.fr>
Sun, 29 Jun 2014 17:26:55 +0000 (18:26 +0100)
committerEtienne Dechamps <etienne@edechamps.fr>
Sat, 9 May 2015 11:14:31 +0000 (12:14 +0100)
This uses the output of "git describe" directly in configure.ac to
determine the version number to use, instead of hardcoding it.

With this change, current version information is completely removed
from the codebase itself, and is always fetched on-the-fly from git as
the single source of truth.

In order to ensure make dist always uses the current version number in
the contents of the packaged configure script as well as the package
name, a dependency is added to the dist target such that autoconf is
always run before dist to regenerate the version number. If this wasn't
the case, make dist would use the version number from when autoconf was
originally run, not the version number that make dist is running from.
That said, errors from that rule are ignored so that people can still
run make dist without a working autoconf.

In addition, the NEWS check is dropped, as it would then become annoying
because it would force make dist users to always have a line for the
current commit in the NEWS file.

Makefile.am
configure.ac

index 0a4faef..9c24561 100644 (file)
@@ -8,6 +8,14 @@ ACLOCAL_AMFLAGS = -I m4
 
 EXTRA_DIST = COPYING.README README.android
 
+# If git describe works, force autoconf to run in order to make sure we have the
+# current version number from git in the resulting configure script.
+configure-version:
+       -git describe && autoconf --force
+
+# Triggering the README target means we are building a distribution (make dist).
+README: configure-version
+
 ChangeLog:
        git log > ChangeLog
 
index 9a9bf01..2672e1c 100644 (file)
@@ -1,10 +1,10 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.61)
-AC_INIT([tinc], [1.1pre11])
+AC_INIT([tinc], m4_esyscmd([echo -n "`git describe || echo UNKNOWN | sed 's/release-//'`"]))
 AC_CONFIG_SRCDIR([src/tincd.c])
 AC_GNU_SOURCE
-AM_INIT_AUTOMAKE([check-news std-options subdir-objects -Wall])
+AM_INIT_AUTOMAKE([std-options subdir-objects -Wall])
 AC_CONFIG_HEADERS([config.h])
 
 # Enable GNU extensions.