summaryrefslogtreecommitdiff
path: root/make_helpers/build_macros.mk
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval@linaro.org>2020-09-10 12:18:27 -0500
committerLeonardo Sandoval <leonardo.sandoval@linaro.org>2020-09-14 09:27:53 -0500
commit327131c4c7e41d57aca9f54fd2706ae59d735aaa (patch)
tree02bec611bb2050129066ce0b8e20b552abcecad9 /make_helpers/build_macros.mk
parented39d5e3c0709bab22821a1da3a62737c5d531de (diff)
downloadarm-trusted-firmware-327131c4c7e41d57aca9f54fd2706ae59d735aaa.tar.gz
build_macros.mk: include assert and define loop macros
Loop macros make it easier for developers to include new variables to assert or define and also help code code readability on makefiles. Change-Id: I0d21d6e67b3eca8976c4d856ac8ccc02c8bb5ffa Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
Diffstat (limited to 'make_helpers/build_macros.mk')
-rw-r--r--make_helpers/build_macros.mk19
1 files changed, 19 insertions, 0 deletions
diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk
index 1c3d14d05..613fca23f 100644
--- a/make_helpers/build_macros.mk
+++ b/make_helpers/build_macros.mk
@@ -44,6 +44,13 @@ define add_define
DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
endef
+
+# Convenience function for addding multiple build definitions
+# $(eval $(call add_defines,FOO BOO))
+define add_defines
+ $(foreach def,$1,$(eval $(call add_define,$(def))))
+endef
+
# Convenience function for adding build definitions
# $(eval $(call add_define_val,FOO,BAR)) will have:
# -DFOO=BAR
@@ -57,6 +64,12 @@ define assert_boolean
$(if $(filter-out 0 1,$($1)),$(error $1 must be boolean))
endef
+# Convenience function for verifying options have boolean values
+# $(eval $(call assert_booleans,FOO BOO)) will assert FOO and BOO for 0 or 1 values
+define assert_booleans
+ $(foreach bool,$1,$(eval $(call assert_boolean,$(bool))))
+endef
+
0-9 := 0 1 2 3 4 5 6 7 8 9
# Function to verify that a given option $(1) contains a numeric value
@@ -67,6 +80,12 @@ $(foreach d,$(0-9),$(eval __numeric := $(subst $(d),,$(__numeric))))
$(if $(__numeric),$(error $(1) must be numeric))
endef
+# Convenience function for verifying options have numeric values
+# $(eval $(call assert_numerics,FOO BOO)) will assert FOO and BOO contain numeric values
+define assert_numerics
+ $(foreach num,$1,$(eval $(call assert_numeric,$(num))))
+endef
+
# CREATE_SEQ is a recursive function to create sequence of numbers from 1 to
# $(2) and assign the sequence to $(1)
define CREATE_SEQ