summaryrefslogtreecommitdiff
path: root/build-aux/no-builtin-variables.mk
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/no-builtin-variables.mk')
-rw-r--r--build-aux/no-builtin-variables.mk15
1 files changed, 15 insertions, 0 deletions
diff --git a/build-aux/no-builtin-variables.mk b/build-aux/no-builtin-variables.mk
new file mode 100644
index 0000000..c3aef58
--- /dev/null
+++ b/build-aux/no-builtin-variables.mk
@@ -0,0 +1,15 @@
+MAKEFLAGS += --no-builtin-variables
+
+# This version is more correct, but is slower:
+# $(foreach v,$(shell bash -c 'comm -23 <(env -i $(MAKE) -f - <<<"\$$(info \$$(.VARIABLES))all:"|sed "s/ /\n/g"|sort) <(env -i $(MAKE) -R -f - <<<"\$$(info \$$(.VARIABLES))all:"|sed "s/ /\n/g"|sort)'),
+# $(if $(filter default,$(origin $v)),$(eval undefine $v)))
+
+_default_variables = $(foreach v,$(.VARIABLES),$(if $(filter default,$(origin $v)),$v))
+$(foreach v,$(filter-out .% MAKE% SUFFIXES,$(_default_variables))\
+ $(filter .LIBPATTERNS MAKEINFO,$(_default_variables)),\
+ $(eval undefine $v))
+undefine _default_variables
+
+# Because Make uses .LIBPATTERNS internally, it should always be
+# defined in case --warn-undefined-variables
+.LIBPATTERNS ?=