summaryrefslogtreecommitdiffstats
path: root/include/make/options.mk
diff options
context:
space:
mode:
Diffstat (limited to 'include/make/options.mk')
-rw-r--r--include/make/options.mk23
1 files changed, 18 insertions, 5 deletions
diff --git a/include/make/options.mk b/include/make/options.mk
index 022981c..d212586 100644
--- a/include/make/options.mk
+++ b/include/make/options.mk
@@ -23,14 +23,15 @@ build_options = $(foreach opt,$(use_opts),$(call ignore_implicit,$(opt)))
# Make a list of all known features with +/- prepended depending on their
# activation status. Must be a macro so that dynamically enabled ones are
# evaluated with their current status.
-build_features = $(foreach opt,$(patsubst USE_%,%,$(sort $(use_opts))),$(if $(USE_$(opt)),+$(opt),-$(opt)))
+build_features = $(foreach opt,$(patsubst USE_%,%,$(sort $(use_opts))),$(if $(USE_$(opt):0=),+$(opt),-$(opt)))
-# This returns a list of -DUSE_* for all known USE_* that are set
-opts_as_defines = $(foreach opt,$(use_opts),$(if $($(opt)),-D$(opt),))
+# This returns a list of -DUSE_* for all known USE_* that are set to anything
+# neither empty nor '0'.
+opts_as_defines = $(foreach opt,$(use_opts),$(if $($(opt):0=),-D$(opt),))
# Lists all enabled or disabled options without the "USE_" prefix
-enabled_opts = $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),$(opt),))
-disabled_opts = $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),,$(opt)))
+enabled_opts = $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt):0=),$(opt),))
+disabled_opts = $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt):0=),,$(opt)))
# preset all XXX_{INC,LIB,CFLAGS,LDFLAGS,SRC} variables to empty for $1=XXX
reset_opt_vars = $(foreach name,INC LIB CFLAGS LDFLAGS SRC,$(eval $(1)_$(name)=))
@@ -50,3 +51,15 @@ endef
# collect all enabled USE_foo's foo_{C,LD}FLAGS into OPTIONS_{C,LD}FLAGS
collect_opts_flags = $(foreach opt,$(enabled_opts),$(eval $(call collect_opt_flags,$(opt))))
+
+# Check that any USE_* variable that was forced actually exist. For this we'll
+# build a list of the MAKEOVERRIDES variables that start with USE_*, and keep
+# the ones that do not match any of the patterns built by appending '=%' to all
+# use_opts. The outstanding ones are thus unknown and each of them produces a
+# warning.
+warn_unknown_options = \
+ $(foreach unknown, \
+ $(filter-out $(foreach opt,$(use_opts),$(opt:==%)), \
+ $(foreach opt,$(MAKEOVERRIDES), \
+ $(strip $(filter USE_%,$(opt))))), \
+ $(warning Warning: ignoring unknown build option: $(unknown)))