I'm using this snippet to get all makefile variables and values:
.PHONY: test
test:
$(foreach v, \
$(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)), \
$(info $(v) = $($(v))))
But I want to write this output to a file.
None of the following works:
...$(info $(v) = $($(v)))) > myfile.txt
...$(info $(v) = $($(v))) >> myfile.txt)
ALL_MAKEFILE_VARS:; $(foreach v, $(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)), $(info $(v)=$($(v))))
.PHONY: test
test:
$(file > myfile.txt,$(ALL_MAKEFILE_VARS))
echo -e $(foreach v, $(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)), $(info $(v)=$($(v)))) > derp.txt
Its so easy to print them, I just want to redirect that output to a file.
Edit
I'm trying to use the file function but I'm running into a few problems.
First problem isn't the file function its the target itself, this always returns make: Nothing to be done for 'test'.
VARS_OLD:= $(.VARIABLES)
.PHONY: test
test:
$(foreach v, \
$(filter-out $(VARS_OLD) VARS_OLD,$(.VARIABLES)), \
$(file >myfile.txt,$(v) = $($(v))))
If I remove the VARS_OLD:= $(.VARIABLES)
I can get it to run but then I see this:
*** Undefined required by target `test`. Stop
It does create a file but it only has this content:
% cat myfile.txt
.LIBPATTERNS = lib%.dylib lib%.a