Skip to contentSkip to conversation

Makefile: fix shell error for darwin major/minor version check

PATCH In review Christian Marangi 3 participants 3 messages Jan 22, 2023 – Feb 7, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: fix shell error for darwin major/minor version check

Fix shell error:
/bin/sh: line 0: [: too many arguments

for the darwin major/minor version check.

It seems for os_x_before for some reason DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION are empty. To fix this set DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION to be evaluated once so the value is retained.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index eb354c045c..fceac081c8 100644
@@ -318,8 +318,8 @@ endif
 #
 ifeq ($(HOSTOS),darwin)
 # get major and minor product version (e.g. '10' and '6' for Snow Leopard)
-DARWIN_MAJOR_VERSION	= $(shell sw_vers -productVersion | cut -f 1 -d '.')
-DARWIN_MINOR_VERSION	= $(shell sw_vers -productVersion | cut -f 2 -d '.')
+DARWIN_MAJOR_VERSION	:= $(shell sw_vers -productVersion | cut -f 1 -d '.')
+DARWIN_MINOR_VERSION	:= $(shell sw_vers -productVersion | cut -f 2 -d '.')
 
 os_x_before	= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
 	$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
Signature · 1 line
2.38.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christian Marangi

Fix shell error:
/bin/sh: line 0: [: too many arguments

for the darwin major/minor version check.

Quoted 9 lines

It seems for os_x_before for some reason DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION are empty. To fix this set DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION to be evaluated once so the value is retained.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#2 lore raw
In reply to Christian Marangi
Quoted 11 lines · Christian Marangi

Fix shell error:
/bin/sh: line 0: [: too many arguments

for the darwin major/minor version check.

It seems for os_x_before for some reason DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION are empty. To fix this set DARWIN_MAJOR_VERSION and DARWIN_MINOR_VERSION to be evaluated once so the value is retained.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom