From a4bb355732f2902b936368b644fa08518ecce55a Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 16 Feb 2024 11:50:39 +0000 Subject: build system: improvements to EXTRAVERSION detection The previous commit to detect EXTRAVERSION more accurately was lacking in some respects: - Only attempt to detect EXTRAVERSION if it's currently set to the default value '.git'. - Use immediate-expansion macro assignments to avoid time-consuming repeated evaluations. - Remove a useless use of cat. - Correctly allow for the output being sent to a separate directory. --- Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 36d66d2d0..c12b7791f 100644 --- a/Makefile +++ b/Makefile @@ -376,24 +376,25 @@ CONFIG_PLATFORM_MINGW32 := $(subst ",,$(CONFIG_PLATFORM_MINGW32)) #") endif -# Try various methods to get a more specific EXTRAVERSION -ifeq ($(CONFIG_PLATFORM_MINGW32),y) +# Try various methods to get a more specific EXTRAVERSION, but only +# for MINGW32 platform and if EXTRAVERSION is default '.git' +ifeq ($(CONFIG_PLATFORM_MINGW32)$(EXTRAVERSION),y.git) # Ask git -extraversion = $(shell git describe --match FRP 2>/dev/null) +extraversion := $(shell cd $(srctree) && git describe --match FRP 2>/dev/null) ifeq ($(strip $(extraversion)),) # That didn't work, look for a .frp_describe file -extraversion = $(shell cat .frp_describe 2>/dev/null | grep '^FRP-') +extraversion := $(shell grep '^FRP-' $(srctree)/.frp_describe 2>/dev/null) ifeq ($(strip $(extraversion)),) -# That didn't work either, look at current directory name -e1 = $(shell basename `pwd` | grep '^busybox-w32-FRP-') +# That didn't work either, look at name of source directory +e1 := $(shell basename $(srctree) | grep '^busybox-w32-FRP-') ifneq ($(strip $(e1)),) -extraversion = $(subst busybox-w32-,,$(e1)) +extraversion := $(subst busybox-w32-,,$(e1)) endif endif endif ifneq ($(strip $(extraversion)),) -EXTRAVERSION = .$(subst FRP,git,$(extraversion)) +EXTRAVERSION := .$(subst FRP,git,$(extraversion)) endif endif -- cgit v1.2.3-55-g6feb