Reputation:
From the docs:
There is one more special feature of target-specific variables: when you define a target-specific variable that variable value is also in effect for all prerequisites of this target, and all their prerequisites, etc. (unless those prerequisites override that variable with their own target-specific variable value).
So, given a makefile:
$(shell rm -rf x D)
$(shell mkdir D)
$(shell touch D/x)
VPATH = D
all: x ;
x ::
@echo 'foo is: $(foo)'
.SILENT : D/x
all : foo = bar
Running, I get:
foo is:
And I thought, that I defined above: foo = bar
!
Or, did I?
Upvotes: 2
Views: 87
Reputation: 4952
In fact you have a mix with VPATH, Double-Colon Rules, Target-specific Variable Values and Special Built-in Target Names.
Your Makefile
can be interpreted as:
all
is the first targetall
have one prerequisite: x
VPATH
is D
, all
have also an indirect prerequisite: D/x
D/x
target is silentall
and all these prerequisites have a target specific variable foo
equal to bar
It seems that the indirect prerequisite D/x
is not taken into account for the target specific thing.
Interresting test: Add x : foo = bar
at the end of your Makefile
and the make
process will be stuck...
Workarounds:
.SILENT
line (I found this after some tests, it also fix the issue above...)D/x : foo = bar
at the end of your Makefile
to explicitely add the foo
variable for the D/x
targetUpvotes: 1