]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Construct full version number automatically from git revision v1.20.1
authorMichael Brown <mcb30@ipxe.org>
Thu, 2 Jan 2020 22:43:15 +0000 (23:43 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 2 Jan 2020 22:54:24 +0000 (23:54 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/Makefile

index c0bc45fa6e470303a79ac1f8c5fdf96796304ad4..a84efd6d66a31006abb725111f228c8cc2b8d9a3 100644 (file)
@@ -207,14 +207,27 @@ install :
 #
 # Version number calculations
 #
+ifneq ($(wildcard ../.git),)
+VERSIONS := $(shell git describe --tags --always --long --abbrev=1 --match "v*")
+VERSION_TUPLE  := $(subst ., ,$(subst -, ,$(patsubst v%,%,$(VERSIONS))))
+VERSION_MAJOR  := $(word 1,$(VERSION_TUPLE))
+VERSION_MINOR  := $(word 2,$(VERSION_TUPLE))
+VERSION_PATCH  := $(word 3,$(VERSION_TUPLE))
+ifeq ($(word 4,$(VERSION_TUPLE)),0)
+EXTRAVERSION   :=
+else
+EXTRAVERSION   := +
+endif
+GITVERSION     = $(word 5,$(VERSION_TUPLE))
+else
 VERSION_MAJOR  = 1
 VERSION_MINOR  = 0
 VERSION_PATCH  = 0
 EXTRAVERSION   = +
+endif
 MM_VERSION     = $(VERSION_MAJOR).$(VERSION_MINOR)
 VERSION                = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
-ifneq ($(wildcard ../.git),)
-GITVERSION := $(shell git describe --always --abbrev=1 --match "" 2>/dev/null)
+ifneq ($(GITVERSION),)
 VERSION                += ($(GITVERSION))
 endif
 version :