In my makefile, I have a variable 'NDK_PROJECT_PATH', my question is how can I print it out when it compiles?
I read Make file echo displaying "$PATH" string and I tried:
@echo $(NDK_PROJECT_PATH) @echo $(value NDK_PROJECT_PATH)
Both gives me
"build-local.mk:102: *** missing separator. Stop."
Any one knows why it is not working for me?
To use it, just set the list of variables to print on the command line, and include the debug target: $ make V="USERNAME SHELL" debug makefile:2: USERNAME = Owner makefile:2: SHELL = /bin/sh.exe make: debug is up to date. Now you can print variables by simply listing them on the command line.
The ' @ ' is discarded before the line is passed to the shell. Typically you would use this for a command whose only effect is to print something, such as an echo command to indicate progress through the makefile: @echo About to make distribution files.
@enchanter You can use echo, but you would need to put it outside the foreach loop, like this: @echo -e $(foreach var,$(. VARIABLES),"$(var)=$($(var))\n") . $(foreach...) concatenates all of the values from the loop, and then executes the result.
You can print out variables as the makefile is read (assuming GNU make as you have tagged this question appropriately) using this method (with a variable named "var"):
$(info $$var is [${var}])
You can add this construct to any recipe to see what make will pass to the shell:
.PHONY: all all: ; $(info $$var is [${var}])echo Hello world
Now, what happens here is that make stores the entire recipe ($(info $$var is [${var}])echo Hello world
) as a single recursively expanded variable. When make decides to run the recipe (for instance when you tell it to build all
), it expands the variable, and then passes each resulting line separately to the shell.
So, in painful detail:
$(info $$var is [${var}])echo Hello world
$(info $$var is [${var}])
$$
becomes literal $
${var}
becomes :-)
(say)$var is [:-)]
appears on standard out$(info...)
though is emptyecho Hello world
echo Hello world
on stdout first to let you know what it's going to ask the shell to doHello world
on stdout.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With