[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: conditionals not working for conditional variables in sub-make?

From: Szekeres István
Subject: Re: conditionals not working for conditional variables in sub-make?
Date: Thu, 7 May 2009 23:39:36 +0200

2009/5/7 Martin Dorey <address@hidden>:
>> But here VAR2 should be "foo"!
> No, it shouldn't, for exactly the same reason that VAR2 isn't foo here:
> address@hidden:~/tmp/bug-make-2009-05-07$ make var1
> VAR=foo VAR2=bar VAR3=foo
> address@hidden:~/tmp/bug-make-2009-05-07$
> Despite the number of exclamation marks, it's not clear why you think VAR2 
> should be foo.

See "Target specific variables" in the make info. In my example the
"var1" rule sets VAR to "foo" (correctly), the "var2" rule sets it to
"bar" (correctly).

>  Do you think VAR was foo when make was started?

No. VAR become foo when the "var1" rule was executed.

> Or do you think that make reevaluates all the code at global scope in the 
> context of every target?

No, it reevaluates because of the explicit "make" commands in the "all" rule.

The "var1" rule sets VAR to foo, and VAR3 is set to $(VAR) globally,
and this works correctly, you can see this even in your own output:

   address@hidden:~/tmp/bug-make-2009-05-07$ make
   make var1
   make[1]: Entering directory `/home/martind/tmp/bug-make-2009-05-07'
   VAR=foo VAR2=bar VAR3=foo

VAR is foo and VAR3 is also foo, correct.

   make[1]: Leaving directory `/home/martind/tmp/bug-make-2009-05-07'
   make var2
   make[1]: Entering directory `/home/martind/tmp/bug-make-2009-05-07'
   VAR=bar VAR2=bar VAR3=bar

VAR is bar and VAR3 is also bar, correct.

The problem is the value of VAR2: in the first case it should be
"foo", because the if statement
   ifeq ($(VAR),foo)

should compare $(VAR) (which is "foo" in the first case) to "foo" -
they are the same  so the then-branch should be executed, setting VAR2
to foo. But in the output you can see that VAR2 is not set to foo, and
this is what I reported in my very first mail.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]