[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with target-specific vars and dependencies
From: |
Boris Kolpackov |
Subject: |
Re: problem with target-specific vars and dependencies |
Date: |
Fri, 6 Aug 2004 15:02:56 +0000 (UTC) |
User-agent: |
nn/6.6.5+RFC1522 |
Tzafrir Cohen <address@hidden> writes:
> My makefile:
>
> c: var=1
>
> c: b
> @echo making $@ from $^, var=$(var)
>
> b: a
> @echo making $@ from $^, var=$(var)
>
> a:
>
>
> $ make b c
> making b from a, var=
> making c from b, var=1
> $ make c
> making b from a, var=1
> making c from b, var=1
>
> Shouldn't 'make b' get the value of 'var' fom the target-specific
> assignment of c?
Yes, if it's built because `c' depends on it (as is the case in your
second invocation). In other words, target-specific variable inheritance
is a dynamic process which takes into account the dependency path that
lead to rebuilt of the target.
IMO, target-specific variable inheritance is quite useless feature
exactly because of this. Also consider something along these lines:
all: a b
a: var := a
b: var := b
a: c
b: c
c:
echo $(var)
When you run make with job server (e.g., make -j 2) there is no way to
predict the output of this makefile. In fact it could be different in
two consequent invocations.
-boris