Patchwork Makefile: add variable print capabilities

login
register
mail settings
Submitter Émeric Vigier
Date July 19, 2012, 7:01 p.m.
Message ID <1342724478-21701-2-git-send-email-emeric.vigier@savoirfairelinux.com>
Download mbox | patch
Permalink /patch/172036/
State Not Applicable
Headers show

Comments

Émeric Vigier - July 19, 2012, 7:01 p.m.
Taken from http://www.cmcrossroads.com/ask-mr-make/
6521-dumping-every-makefile-variable

Signed-off-by: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
---
 Makefile |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

Patch

diff --git a/Makefile b/Makefile
index d55b136..901c3c3 100644
--- a/Makefile
+++ b/Makefile
@@ -369,7 +369,8 @@  world: prepare dirs dependencies $(BASE_TARGETS) $(TARGETS_ALL)
 	$(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
 	$(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) $(TARGETS_LEGAL_INFO) \
 	$(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
-	$(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR)
+	$(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR) \
+	printvars
 
 #############################################################
 #
@@ -377,6 +378,14 @@  world: prepare dirs dependencies $(BASE_TARGETS) $(TARGETS_ALL)
 # dependencies anywhere else
 #
 #############################################################
+printvars:
+	@$(foreach V,$(sort $(.VARIABLES)), \
+	$(if $(filter-out environment% default automatic, \
+	$(origin $V)),$(warning $V=$($V) ($(value $V)))))
+
+print-%:
+	@echo $* = $($*)
+
 $(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR):
 	@mkdir -p $@