Hi Jeff,

Am Fri, 14 Jan 2011 11:38:29 -0600
schrieb JeffS <[email protected]>:

> 
> Hi!  I'm using GNU Make 3.80.  In my Makefile, I use automatic
> variable $@  to refer to the current target, as shown below.
> 
>         |     @echo current target is ... [$@]
>         ifeq ($@,sms)
>              @echo yep, they are equal
>         else
>              @echo no, they are not equal
>         endif
>         |
> 
> It seems that $@  expands to sms , as shown in the output below.
> 
> Output is:
> 
>         |current target is ... [sms]
>         no, they are not equal
>         |
> 
> My question: since $@  (apparently) expands to sms 
at rule execution time
> , shouldn't the  "true" branch of the ifeq  conditional be executed
> (with the consequence that the output should read yep, they are
> equal)? 
No, as that get evaluated at rule parsing long before rule execution.
>[I am at a loss as to why the output is no, they are not equal.]
> 
> Thank you for any advice you can provide.

try this:

COMMA := ,
sms:
        @echo $(if $(filter sms,$@),\
                yep$(COMMA) they are equal,\
                no$(COMMA) they are not equal)

notsms:
        @echo $(if $(filter sms,$@),\
                yep$(COMMA) they are equal,\
                no$(COMMA) they are not equal)

BR,

Bjoern


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to