[PATCH v4 1/5] tools build: Fix version-ge3 and version-lt3 for <3-part versions
From: Ian Rogers
Date: Wed Nov 11 2026 - 20:18:56 EST
version-ge3 and version-lt3 concatenate their two arguments as
"$(1).$(2)" and parse fields $1..$6 with awk -F'.'. When $(1) is empty
or has fewer than three dot-separated components (for example GCC's
1- or 2-part -dumpversion output), fields $4..$6 shift across the
boundary between $(1) and $(2). In particular, calling version-lt3 with
an empty $(1) against "14.0.0" evaluates 0 < 0 and returns 0 (false).
Pass $(1) and $(2) as separate awk variables and split each into its own
array so missing components default to 0 without shifting fields across
arguments.
Fixes: a9b451509565 ("tools build: Add 3-component logical version comparators")
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/scripts/utilities.mak | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/scripts/utilities.mak b/tools/scripts/utilities.mak
index d69d0345cc23..746aaf6e5145 100644
--- a/tools/scripts/utilities.mak
+++ b/tools/scripts/utilities.mak
@@ -186,7 +186,7 @@ _gea_err = $(if $(1),$(error Please set '$(1)' appropriately))
# was to check the flex version to see if we can use compiler warnings as
# errors for one of the cases flex generates code C compilers complains about.
-version-ge3 = $(shell echo "$(1).$(2)" | awk -F'.' '{ printf("%d\n", (10000000 * $$1 + 10000 * $$2 + $$3) >= (10000000 * $$4 + 10000 * $$5 + $$6)) }')
+version-ge3 = $(shell awk -v v1="$(1)" -v v2="$(2)" 'BEGIN { split(v1, a, "."); split(v2, b, "."); printf("%d\n", (10000000 * a[1] + 10000 * a[2] + a[3]) >= (10000000 * b[1] + 10000 * b[2] + b[3])) }')
# version-lt3
#
@@ -196,4 +196,4 @@ version-ge3 = $(shell echo "$(1).$(2)" | awk -F'.' '{ printf("%d\n", (10000000 *
# check the flex version to see if we can use compiler warnings as errors for
# one of the cases flex generates code C compilers complains about.
-version-lt3 = $(shell echo "$(1).$(2)" | awk -F'.' '{ printf("%d\n", (10000000 * $$1 + 10000 * $$2 + $$3) < (10000000 * $$4 + 10000 * $$5 + $$6)) }')
+version-lt3 = $(shell awk -v v1="$(1)" -v v2="$(2)" 'BEGIN { split(v1, a, "."); split(v2, b, "."); printf("%d\n", (10000000 * a[1] + 10000 * a[2] + a[3]) < (10000000 * b[1] + 10000 * b[2] + b[3])) }')
--
2.56.0.567.gdb80ae8cd5-goog