Skip to content

Commit a9b4515

Browse files
committed
tools build: Add 3-component logical version comparators
The next cset needs to compare if a flex version is greater or equal/less than another, but since there is no canonical, generally available way to compare versions in the command line (sort -V, yeah, but...), just use awk to canonicalize the versions like is also done in scripts/rust_is_available.sh. There was a problem spotted in linux-next where a bashism, here documents, aka the '<<<' stdin redirector, for strings to be used as the stdin for awk. Use $(shell echo | awk ...) instead. Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent e5764ae commit a9b4515

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tools/scripts/utilities.mak

+20
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,23 @@ $(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2)))
177177
endef
178178
_ge_attempt = $(or $(get-executable),$(call _gea_err,$(2)))
179179
_gea_err = $(if $(1),$(error Please set '$(1)' appropriately))
180+
181+
# version-ge3
182+
#
183+
# Usage $(call version-ge3,2.6.4,$(FLEX_VERSION))
184+
#
185+
# To compare if a 3 component version is greater or equal to another, first use
186+
# was to check the flex version to see if we can use compiler warnings as
187+
# errors for one of the cases flex generates code C compilers complains about.
188+
189+
version-ge3 = $(shell echo "$(1).$(2)" | awk -F'.' '{ printf("%d\n", (10000000 * $$1 + 10000 * $$2 + $$3) >= (10000000 * $$4 + 10000 * $$5 + $$6)) }')
190+
191+
# version-lt3
192+
#
193+
# Usage $(call version-lt3,2.6.2,$(FLEX_VERSION))
194+
#
195+
# To compare if a 3 component version is less thjan another, first use was to
196+
# check the flex version to see if we can use compiler warnings as errors for
197+
# one of the cases flex generates code C compilers complains about.
198+
199+
version-lt3 = $(shell echo "$(1).$(2)" | awk -F'.' '{ printf("%d\n", (10000000 * $$1 + 10000 * $$2 + $$3) < (10000000 * $$4 + 10000 * $$5 + $$6)) }')

0 commit comments

Comments
 (0)