Reputation: 9109
I have such Makefile:
print: var1=inside
print:
@echo $(var1)
When I run var1=outside make -e print
. I expected to see:
outside
Variables provided on the command line (and in the environment if the ‘-e’ option is in force) will take precedence.
But I get:
inside
Is it a correct output?
Upvotes: 2
Views: 132
Reputation: 100781
It is expected; whether or not it's correct I guess depends on who you ask.
The -e
option is in effect for "global" variables in makefiles, but target-specific variables take precedence over globally-scoped variables.
Personally I think -e
was a mistake and never should have existed. But, you know, POSIX and all. Even though it exists I recommend that it be avoided. It's far, far too easy to completely mess up your build in confusing and surprising ways.
ETA Well, maybe it's not expected. Maybe it is a bug. Where did you get that quote you provided? With just that sentence from a 225-page document it's hard to say... a link or at least a section name would be helpful.
Upvotes: 2