Browse Source

[build] Construct full version number automatically from git revision

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 4 years ago
parent
commit
8f1514a004
1 changed files with 15 additions and 2 deletions
  1. 15
    2
      src/Makefile

+ 15
- 2
src/Makefile View File

207
 #
207
 #
208
 # Version number calculations
208
 # Version number calculations
209
 #
209
 #
210
+ifneq ($(wildcard ../.git),)
211
+VERSIONS := $(shell git describe --tags --always --long --abbrev=1 --match "v*")
212
+VERSION_TUPLE	:= $(subst ., ,$(subst -, ,$(patsubst v%,%,$(VERSIONS))))
213
+VERSION_MAJOR	:= $(word 1,$(VERSION_TUPLE))
214
+VERSION_MINOR	:= $(word 2,$(VERSION_TUPLE))
215
+VERSION_PATCH	:= $(word 3,$(VERSION_TUPLE))
216
+ifeq ($(word 4,$(VERSION_TUPLE)),0)
217
+EXTRAVERSION	:=
218
+else
219
+EXTRAVERSION	:= +
220
+endif
221
+GITVERSION	= $(word 5,$(VERSION_TUPLE))
222
+else
210
 VERSION_MAJOR	= 1
223
 VERSION_MAJOR	= 1
211
 VERSION_MINOR	= 0
224
 VERSION_MINOR	= 0
212
 VERSION_PATCH	= 0
225
 VERSION_PATCH	= 0
213
 EXTRAVERSION	= +
226
 EXTRAVERSION	= +
227
+endif
214
 MM_VERSION	= $(VERSION_MAJOR).$(VERSION_MINOR)
228
 MM_VERSION	= $(VERSION_MAJOR).$(VERSION_MINOR)
215
 VERSION		= $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
229
 VERSION		= $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
216
-ifneq ($(wildcard ../.git),)
217
-GITVERSION := $(shell git describe --always --abbrev=1 --match "" 2>/dev/null)
230
+ifneq ($(GITVERSION),)
218
 VERSION		+= ($(GITVERSION))
231
 VERSION		+= ($(GITVERSION))
219
 endif
232
 endif
220
 version :
233
 version :

Loading…
Cancel
Save