-
Notifications
You must be signed in to change notification settings - Fork 7
/
target.printvar.inc.mk
51 lines (40 loc) · 1.4 KB
/
target.printvar.inc.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# see https://blog.melski.net/2010/11/30/makefile-hacks-print-the-value-of-any-variable/
# see https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
MAKEFILE_ORIGINS := \
default \
environment \
environment\ override \
file \
command\ line \
override \
automatic \
\%
PRINTVARS_VARIABLES_IGNORE += \
exportifdef \
global-which \
ifdef_any_of \
ifndef_any_of \
which \
PRINTVARS_MAKEFILE_ORIGINS_TARGETS += \
$(patsubst %,printvars/%,$(MAKEFILE_ORIGINS)) \
# ------------------------------------------------------------------------------
.PHONY: printvars
printvars: printvars/file ## Print all Makefile variables (file origin).
.PHONY: $(PRINTVARS_MAKEFILE_ORIGINS_TARGETS)
$(PRINTVARS_MAKEFILE_ORIGINS_TARGETS):
@$(foreach V, $(sort $(filter-out $(PRINTVARS_VARIABLES_IGNORE),$(.VARIABLES))), \
$(if $(filter $(@:printvars/%=%), $(origin $V)), \
$(warning $V=$($V) ($(value $V)))))
@$(foreach V, $(sort $(filter $(PRINTVARS_VARIABLES_IGNORE),$(.VARIABLES))), \
$(if $(filter $(@:printvars/%=%), $(origin $V)), \
$(warning $V was skipped based on PRINTVARS_VARIABLES_IGNORE.)))
.PHONY: printvars/lazy
printvars/lazy:
@$(foreach V, $(sort $(.VARIABLES_LAZY)), \
$(warning $V=$($V)))
.PHONY: printvar-%
printvar-%: ## Print one Makefile variable.
@$(ECHO) $*=$($*)
@$(ECHO) ' origin = $(origin $*)'
@$(ECHO) ' flavor = $(flavor $*)'
@$(ECHO) ' value = $(value $*)'