@@ -89,6 +89,24 @@ find-in-path = $(if $(find-string /, $1), \
$(wildcard $1), \
$(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH)))))
+# Logical functions (for operating on y/n values like CONFIG_FOO vars)
+# Inputs to these must be either "y" (true) or "n" or "" (both false)
+# Output is always either "y" or "n".
+# Usage: $(call land,$(CONFIG_FOO),$(CONFIG_BAR))
+# Logical NOT
+lnot = $(if $(subst n,,$1),n,y)
+# Logical AND
+land = $(if $(findstring yy,$1$2),y,n)
+# Logical OR
+lor = $(if $(findstring y,$1$2),y,n)
+# Comparison: note that "n" is eq to "".
+eq = $(if $(filter $(call lnot,$1),$(call lnot,$2)),y,n)
+ne = $(if $(filter $(call lnot,$1),$(call lnot,$2)),n,y)
+
+# Returns "y" or "n" depending on whether input argument is the empty string
+isempty = $(if $1,n,y)
+notempty = $(if $1,y,n)
+
# Generate files with tracetool
TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py
Add new logical functions for handling y/n values like those we use in CONFIG_FOO variables: lnot : logical NOT land : logical AND lor : logical OR eq : equality ne : non-equality lif : like Make's $(if) but with an eq-like test and a couple of utility functions: isempty : true if argument is empty notempty : true if argument is not empty Based on an idea by Ákos Kovács <akoskovacs@gmx.com>. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- rules.mak | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)