]> sigrok.org Git - libsigrok.git/commit - m4/sigrok.m4
make: move version suffix gathering from configure to compile time
authorGerhard Sittig <redacted>
Sat, 18 Mar 2023 16:18:15 +0000 (17:18 +0100)
committerGerhard Sittig <redacted>
Sun, 9 Apr 2023 22:41:39 +0000 (00:41 +0200)
commit5bce22ac654fa45cdab49152bb3633ea77b4b7fc
tree8b79332517dc473bcc2bab20267a411260efcad9
parent44f0adb65cfec90c0cbc6292ada335a5b80d533d
make: move version suffix gathering from configure to compile time

Check at configure time whether version control is available. Determine
at configure time which branch is being worked on, and re-configure when
the branch changes. Append "-git" to the package version when the source
tree is not tagged at configure time.

Get revision numbers and the dirty flag at compile time. Check whether
the source code revision exactly matches a tag at compile time. Derive
the version suffix from these details. Generate a git-version.h header
file which only the version.c source file references.

This embeds detailled version information into the library, where it is
available at runtime for the library and for applications. And severely
speeds up development iterations by avoiding full rebuilds of the whole
library when a git commit happened. The dirty flag may either require a
manual reconfiguration, or 'make version-clean', if that workspace state
is not automatically picked up. Which is considered acceptable for now,
because builds for distribution should always start with the configure
phase anyway. This uncertainty could only get avoided at the cost of
always creating the git-version.h header file in every build invocation.
Which would be easy to achieve, but remains for a future commit.

The approach was outlined by Martin Ling in 2018-09, see bug #1283. This
implementation additionally handles out-of-source builds, uses positive
logic for the header inclusion, and handles distribution builds from
tarballs or other non-versioned sources (assumes an empty suffix then).
Could also handle other sources of version details, or alternative VCS
implementations, thus passes more variables than strictly necessary from
configuration to compilation.
.gitignore
Makefile.am
configure.ac
include/libsigrok/version.h.in
m4/sigrok.m4
src/version.c