help-make
[Top][All Lists]
Advanced

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

Re: Does $if function really do a $strip before checking condition?(solv


From: Chen Jun (陈军)
Subject: Re: Does $if function really do a $strip before checking condition?(solved)
Date: Wed, 23 Dec 2009 12:50:13 +0800
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Chen Jun (陈军) wrote:
Hello. I have such a makefile

##############################
var=
var+=
       # var contains a space


all:
@$(if $(var),echo "direct: var is NOT empty",echo "direct: var is empty")
##############################

On make 3.80 & 3.81, it both outputs

direct: var is NOT empty

However, make 3.81 doc ch 8.4 says

{quote}

|$(if condition,then-part[,else-part])|

...

The first argument, condition, first has all preceding and trailing whitespace stripped, then is expanded. If it expands to any non-empty string, then the condition is considered to be true. If it expands to an empty string, the condition is considered to be false.
{quote}

Then why my makefile outputs "var is NOT empty" when $(var) would definitely strip down to a null string? Can someone help explain this?




Sorry to bother you all. I figure out the reason myself. The doc say condition is first strip-ed, followed by variable expansion. The most important point: after expansion, it will not strip a second time. So the result.





reply via email to

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