diff --git a/Makefile b/Makefile index 99a34c1600..0b8c7b2867 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,7 @@ nobuild_targets := source %-source \ clean distclean help show-targets graph-depends \ %-graph-depends %-show-depends %-show-version \ graph-build graph-size list-defconfigs \ - savedefconfig update-defconfig printvars + savedefconfig update-defconfig printvars show-vars ifeq ($(MAKECMDGOALS),) BR_BUILDING = y else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),) @@ -1062,6 +1062,7 @@ endif # Makefiles. Alternatively, if a non-empty VARS variable is passed, # only the variables matching the make pattern passed in VARS are # displayed. +# show-vars does the same, but as a JSON dictionnary. .PHONY: printvars printvars: @: @@ -1074,6 +1075,22 @@ printvars: $(info $V=$(if $(RAW_VARS),$(value $V),$($V)))))) # ')))) # Syntax colouring... +.PHONY: show-vars +show-vars: VARS?=% +show-vars: + @: + $(info $(call clean-json, { \ + $(foreach V, \ + $(sort $(filter $(VARS),$(.VARIABLES))), \ + $(if $(filter-out environment% default automatic, $(origin $V)), \ + "$V": { \ + "expanded": $(call mk-json-str,$($V))$(comma) \ + "raw": $(call mk-json-str,$(value $V)) \ + }$(comma) \ + ) \ + ) \ + } )) + .PHONY: clean clean: rm -rf $(BASE_TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) $(HOST_DIR_SYMLINK) \ @@ -1166,6 +1183,8 @@ help: @echo ' pkg-stats - generate info about packages as JSON and HTML' @echo ' missing-cpe - generate XML snippets for missing CPE identifiers' @echo ' printvars - dump internal variables selected with VARS=...' + @echo ' show-vars - dump all internal variables as a JSON blurb; use VARS=...' + @echo ' to limit the list to variables names matching that pattern' @echo @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build' @echo ' make O=dir - Locate all output files in "dir", including .config'