I am trying to do a simple thing:
TMPDIR ?= /tmp
test:
@echo $(TMPDIR)
This works if I run:
$ make test
/tmp
It also works if I run:
$ make test -e TMPDIR=~/tmp
/home/user/tmp
What can I do to also have it works for:
$ TMPDIR=~/tmp make test
/home/user/tmp
?=
and you have an environment variable set, then the value of the environment variable will be used instead). What exactly is the problem (why do you think it doesn't work)?TMPDIR ?= "/tmp"
andecho $(TMPDIR)
the only thing is not to forget the parenthesis around the variable name.-e
backwards.-e
says to allow env vars to override variables defined in the makefile, they don't affect variable assignment coming from command line arguments.?=
does work. If it's not doing what you want then either your explanation above is confusing and we're not understanding what you want, or there's something about your real environment which is not reflected in your question above.