(Re-adding list.) > First run > Second run Make is run three times, once by the human, twice by the makefile. I'm not sure what you mean with this numbering. I think you mean the first and second runs of the echo command in the do-echo rule but please correct me if I'm wrong. > These can clearly be seen in your output. I'll reproduce the two lines of echo output here for clarity: VAR=foo VAR2=bar VAR3=foo VAR=bar VAR2=bar VAR3=bar > if in the first run VAR3 can pick up the value "foo", indicating > that VAR is also "foo" In the first line that I quote above, which is produced by a child of the second make invocation - the one tasked with building var1 - VAR3 is evaluated during the invocation of the do-echo rule as a prerequisite of the var1 rule. Per: >> 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 This means that var1's target-specific assignment of foo to VAR is in effect. VAR3 is defined using deferred evaluation - "=" rather than ":=" - so the right-hand side of the assignment is deferred to evaluation-time. At evaluation time, as we've seen, the right-hand side - "$(VAR)" - is "foo". > why does the statement ifeq($(VAR),foo) fail? That statement is evaluated during an earlier phase of make's execution. It's not reevaluated for every target. At the time, and in the scope, when it was evaluated, $(VAR) was unset, hence empty. -----Original Message----- From: Szekeres István [mailto:szeke...@iii.hu] Sent: Thursday, May 07, 2009 14:50 To: Martin Dorey Subject: Re: conditionals not working for conditional variables in sub-make? 2009/5/7 Martin Dorey <mdo...@bluearc.com>: >> VAR become foo when the "var1" rule was executed. >> it reevaluates because of the explicit "make" commands in the "all" rule. > > Think about the order in which those two things happen. > > The second one happens before the first and hence doesn't see the first's > effect. > > A thought experiment might help you to see the light. Imagine in the "all" > rule, that instead of running "make var1", you ran > "a-script-which-happens-to-invoke-make-var1". Sorry I am still not convinced. First run: VAR=foo, VAR3 picks up the value of VAR, becoming also foo, correct. Second run: VAR=bar, VAR3 picks up the value of VAR, becoming also bar, correct. Can we agree that these two statements are OK? These can clearly be seen in your output. BUT: if in the first run VAR3 can pick up the value "foo", indicating that VAR is also "foo", then why does the statement ifeq($(VAR),foo) fail???
_______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make