configure Make: More detailed version information

Version information is in output of commands version, xdump version,
and in program output for option -v.  Looks like this:

    Wolfpack Empire 4.3.33

The version number is defined in configure.ac, and incremented
manually.  It identifies only the base release (here: 4.3.33).  Fine
when this is an unmodified released version.  Pretty much useless
during development.

Add a suffix to the version number that describes it further:

    V               Unmodified release V (same as before)
    V.N-H           Modified release built from a clean git tree
                    N is the number of additional commits, and
                    H is the abbreviated commit hash
    V.N-H-dirty     Same, but the working tree is dirty
    V-dirty         Modified release built from a tarball

A git tree is clean when the contents of its files are unchanged.
Changing only the their timestamps doesn't count.  It does count when
building from a tarball, because tracking contents isn't implemented
there.

Also use this suffixed version for tarball names.

The version reported by configure is fixed at configure generation
time, i.e. it is usually out of date during development.  Ensuring a
release tarball contains one with a current version is manual for now.
Running autoconf -f should do the trick.

Elsewhere, the version is determined at build time, so it is always
current.

Dirty tracking isn't implemented in the standalone client build.  If
you start with a clean tarball, the version will not change from V to
V-dirty when you build with modifications.

Steal build-aux/git-version-gen from autoconf 2.69 to help with
computing the version string.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-06-26 11:36:04 +02:00
parent db055aa8bc
commit 1ec9b94f74
7 changed files with 266 additions and 12 deletions

26
Make.mk
View file

@ -47,8 +47,13 @@ all:
# Source files
ifeq ($(revctrl),git)
src := $(shell cd $(srcdir) && git ls-files | uniq)
version := $(shell cd $(srcdir) && build-aux/git-version-gen /dev/null)
else
include $(srcdir)/sources.mk
version := $(shell cat $(srcdir)/.tarball-version || echo "UNKNOWN")
endif
ifeq ($(version),UNKNOWN)
$(error cannot figure out version)
endif
dirs := $(sort $(dir $(src)))
csrc := $(filter %.c, $(src))
@ -333,6 +338,19 @@ $(libs) $(empth_lib):
$(call quiet-command,$(AR) rc $@ $?,AR $@)
$(RANLIB) $@
src/lib/global/version.o: CPPFLAGS += -DVERSION='"$(version)"'
src/lib/global/version.o: $(src)
ifneq ($(revctrl),git)
$(srcdir)/.tarball-version: $(src)
v=`sed -e 's/-dirty$$//' <$@`; echo "$$v-dirty" >$@
# Force Make to start over after updating .tarball-version, so that
# $(version) gets the new value
$(srcdir)/.dirty-stamp: .tarball-version
>$@
include $(srcdir)/.dirty-stamp
endif
# Info formatting
# mksubj.pl reads $(tsrc) and writes $(tsubj). A naive rule
@ -367,7 +385,7 @@ info.ps: info/TROFF.MAC info/INFO.MAC info/TOP.t $(tsubj) $(tsrc)
.PHONY: dist-source
dist-source: $(src_distgen)
$(tarball) $(TARNAME)-$(VERSION) -C $(srcdir) $(src_distgen) $(src)
$(tarball) $(TARNAME) $(version) -C $(srcdir) $(src_distgen) $(src)
ifeq ($(revctrl),git)
.PHONY: $(srcdir)/sources.mk
@ -377,7 +395,7 @@ endif
.PHONY: dist-client
dist-client: $(cli_distgen)
$(tarball) $(TARNAME)-client-$(VERSION) \
$(tarball) $(TARNAME)-client $(version) \
-C $(srcdir)/src/client \
$(notdir $(filter src/client/%, $(src)) $(cli_distgen)) \
-C $(srcdir)/include proto.h version.h \
@ -389,8 +407,8 @@ dist-client: $(cli_distgen)
.PHONY: dist-info
dist-info: info html
$(tarball) $(TARNAME)-info-text-$(VERSION) -C info.nr $(info)
$(tarball) $(TARNAME)-info-html-$(VERSION) -C info.html $(addsuffix .html, $(info))
$(tarball) $(TARNAME)-info-text $(version) -C info.nr $(info)
$(tarball) $(TARNAME)-info-html $(version) -C info.html $(addsuffix .html, $(info))
# Dependencies