How to print environment variables from makefile?
You can do exactly as you say in the question. For example:
Here's the Makefile:
.PHONY: all
all: ; $(info VAR='$(VAR)')
Now set the environment variable VAR on the command line before running make:
$ VAR=foo make
VAR='foo'
make: Nothing to be done for 'all'.
Or export it and then run make:
$ export VAR=bar
$ make
VAR='bar'
make: Nothing to be done for 'all'.
So, you need to look elsewhere to find out why this is not working for you.
Note that you don't need to put the $(info)
in a recipe; For example here's a one line makefile printing an environment variable:
Makefile:
$(info VAR='$(VAR)')
Set the environment variable VAR and run make:
$ VAR=foo make
VAR='foo'
make: *** No targets. Stop.