diff mbox series

[v7,04/11] rules.mak: Add strequal() and startswith() rules

Message ID 20200605175821.20926-5-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series accel: Allow targets to use Kconfig | expand

Commit Message

Philippe Mathieu-Daudé June 5, 2020, 5:58 p.m. UTC
Add a rule to test if two strings are equal,
and another to test if a string starts with a substring.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 rules.mak | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Richard Henderson June 5, 2020, 9:50 p.m. UTC | #1
On 6/5/20 10:58 AM, Philippe Mathieu-Daudé wrote:
> Add a rule to test if two strings are equal,
> and another to test if a string starts with a substring.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  rules.mak | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/rules.mak b/rules.mak
index 694865b63e..7b58a6b8c5 100644
--- a/rules.mak
+++ b/rules.mak
@@ -191,6 +191,20 @@  ne = $(if $(subst $2,,$1)$(subst $1,,$2),y,n)
 isempty = $(if $1,n,y)
 notempty = $(if $1,y,n)
 
+# strequal
+# Usage: $(call strequal, str1, str2)
+#
+# This macro returns a string (TRUE) when @str1 and @str2
+# are equal, else returns the empty string (FALSE)
+strequal = $(if $(subst $2,,$1)$(subst $1,,$2),,$1)
+
+# startswith
+# Usage: $(call startswith, startstr, fullstr)
+#
+# This macro returns a string (TRUE) when @fullstr starts with
+# @startstr, else returns the empty string (FALSE)
+startswith = $(findstring :$1,:$2)
+
 # Generate files with tracetool
 TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py