aboutsummaryrefslogtreecommitdiff
path: root/mk/checkconf.mk
diff options
context:
space:
mode:
authorJerome Forissier <jerome.forissier@linaro.org>2014-11-14 17:13:40 +0100
committerJerome Forissier <jerome.forissier@linaro.org>2014-11-25 15:15:42 +0100
commit0a7f95b9a565475390f041e6adc50974c049e3cd (patch)
tree7d4dcb3ba186fcd4947fb28359dbed26b50ef96c /mk/checkconf.mk
parentd8e06e12b1fb85fda098ba4e6936d9230278adbf (diff)
mk/checkconf.mk: add utility functions to test configuration variables
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Diffstat (limited to 'mk/checkconf.mk')
-rw-r--r--mk/checkconf.mk53
1 files changed, 50 insertions, 3 deletions
diff --git a/mk/checkconf.mk b/mk/checkconf.mk
index 863b81ad..1b6afa7c 100644
--- a/mk/checkconf.mk
+++ b/mk/checkconf.mk
@@ -2,7 +2,7 @@
# variables
#
# Example usage (by default, check-conf-h will consider all CFG_*
-# variables):
+# and _CFG_* variables):
#
# path/to/conf.h: FORCE
# $(call check-conf-h)
@@ -11,7 +11,6 @@
#
# path/to/crypto_config.h: FORCE
# $(call check-conf-h,CFG_CRYPTO_ CRYPTO_)
-
define check-conf-h
$(q)set -e; \
echo ' CHK $@'; \
@@ -34,7 +33,7 @@ endef
define cfg-vars-by-prefix
$(strip $(if $(1),$(call _cfg-vars-by-prefix,$(1)),
- $(call _cfg-vars-by-prefix,CFG_)))
+ $(call _cfg-vars-by-prefix,CFG_ _CFG_)))
endef
define _cfg-vars-by-prefix
@@ -52,3 +51,51 @@ define cfg-make-define
/* $1 is not set ('$($1)') */_nl_,
#define $1 $($1) /* '$($1)' */_nl_)))
endef
+
+# Returns 'y' if at least one variable is 'y', empty otherwise
+# Example:
+# FOO_OR_BAR := $(call cfg-one-enabled, FOO BAR)
+cfg-one-enabled = $(if $(filter y, $(foreach var,$(1),$($(var)))),y,)
+
+# Returns 'y' if all variables are 'y', empty otherwise
+# Example:
+# FOO_AND_BAR := $(call cfg-all-enabled, FOO BAR)
+cfg-all-enabled = \
+ $(strip \
+ $(if $(1), \
+ $(if $(filter y,$($(firstword $(1)))), \
+ $(call cfg-all-enabled,$(filter-out $(firstword $(1)),$(1))), \
+ ), \
+ y \
+ ) \
+ )
+
+# Disable a configuration variable if some dependency is disabled
+# Example:
+# $(eval $(call cfg-depends-all,FOO,BAR BAZ))
+# Will clear FOO if it is initially 'y' and BAR or BAZ are not 'y'
+cfg-depends-all = \
+ $(strip \
+ $(if $(filter y, $($(1))), \
+ $(if $(call cfg-all-enabled,$(2)), \
+ , \
+ $(warning Warning: Disabling $(1) [requires $(strip $(2))]) \
+ override $(1) := \
+ ) \
+ ) \
+ )
+
+# Disable a configuration variable if all dependencies are disabled
+# Example:
+# $(eval $(call cfg-depends-one,FOO,BAR BAZ))
+# Will clear FOO if it is initially 'y' and both BAR and BAZ are not 'y'
+cfg-depends-one = \
+ $(strip \
+ $(if $(filter y, $($(1))), \
+ $(if $(call cfg-one-enabled,$(2)), \
+ , \
+ $(warning Warning: Disabling $(1) [requires (one of) $(strip $(2))]) \
+ override $(1) := \
+ ) \
+ ) \
+ )