mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-15 21:21:49 -04:00
kbuild: add test-{ge,gt,le,lt} macros
GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
integers without forking a new process.
Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
Make >= 4.4. For older Make versions, they fall back to the 'test'
shell command.
The first two parameters to $(intcmp ...) must not be empty. To avoid
the syntax error, I appended '0' to them. Fortunately, '00' is treated
as '0'. This is needed because CONFIG options may expand to an empty
string when the kernel configuration is not included.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
This commit is contained in:
@@ -11,6 +11,22 @@ space := $(empty) $(empty)
|
||||
space_escape := _-_SPACE_-_
|
||||
pound := \#
|
||||
|
||||
###
|
||||
# Comparison macros.
|
||||
# Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000)
|
||||
#
|
||||
# Use $(intcmp ...) if supported. (Make >= 4.4)
|
||||
# Otherwise, fall back to the 'test' shell command.
|
||||
ifeq ($(intcmp 1,0,,,y),y)
|
||||
test-ge = $(intcmp $(strip $1)0, $(strip $2)0,,y,y)
|
||||
test-gt = $(intcmp $(strip $1)0, $(strip $2)0,,,y)
|
||||
else
|
||||
test-ge = $(shell test $(strip $1)0 -ge $(strip $2)0 && echo y)
|
||||
test-gt = $(shell test $(strip $1)0 -gt $(strip $2)0 && echo y)
|
||||
endif
|
||||
test-le = $(call test-ge, $2, $1)
|
||||
test-lt = $(call test-gt, $2, $1)
|
||||
|
||||
###
|
||||
# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
|
||||
dot-target = $(dir $@).$(notdir $@)
|
||||
|
||||
Reference in New Issue
Block a user