help-make
[Top][All Lists]
Advanced

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

Re: Wierd if function behaviour


From: Paul Smith
Subject: Re: Wierd if function behaviour
Date: Sat, 30 Jul 2016 17:55:09 -0400

Please always reply to the mailing list, not to me personally.

On Sat, 2016-07-30 at 22:39 +0100, Lee Shallis wrote:
> On 30 July 2016 at 13:47, Paul Smith <address@hidden> wrote:
> > The strange formatting makes this hard to read, but:
> > 
> >   $(info $(0)_CALL=(if ifeq ...
> >                   ^^^
> >                   missing $
> > 
> 
> No that was deliberate, it's meant to tell me which value I'm looking
> at in the output.
> As for the if not having a $ that was so I could see what the previous
> statement looked like was before it was fully evaluated.
> 
> It's just this bit I need you to analyse:
> > $(eval $(0)_CALL=$(if ifeq "$($(0)_PREVMOD)" 
> > "$($(0)_LASTMOD)",_UPTODATE,_UPDATECC))
>                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Well, $(if ifeq ...) is always true, because the result of expanding
that value will never be the empty string.

You seem to be under the impression that the "condition" passed to the
if-function is related to the ifeq/ifneq/ifdef/ifndef conditional
syntax; it's not.

The docs say:

> 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.

In your example, the condition argument is:

    ifeq "$($(0)_PREVMOD)" "$($(0)_LASTMOD)"

After that is expanded, it will be this string:

    ifeq "0" "25/07/2016;10:38"

That string is manifestly a non-empty string, so the condition will be
considered true.

You probably want to use filter-out to see if the value of the first is
identical to the second; something like:

   $(if $(filter-out <first>,<second>),<run-if-not-equal>,<run-if-equal>)

Note the reversal of the then- and else-arguments: here if the values
are equal then the filter-out returns an empty string, which means the
condition is considered false.



reply via email to

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