[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: confusing ifeq behavior
From: |
Ken Smith |
Subject: |
Re: confusing ifeq behavior |
Date: |
Tue, 6 Sep 2005 12:25:12 -0400 |
User-agent: |
Mutt/1.5.10i |
On Tue, Sep 06, 2005 at 08:54:49AM -0700, address@hidden wrote:
>
> Hi,
>
>
> I am seeing what appears to be a false positive with the 'ifeq'
> conditional in make. An example of the problem can be reproduced in
> the following snippette:
>
>
>
> ALL_BLOCKS := a b c d e
>
> SOME_BLOCKS := c d
>
>
> $(ALL_BLOCKS):
>
> @echo "the target is ->$@<-"
>
> ifeq ($@, $(filter $@, $(SOME_BLOCKS)))
I see two interesting things about this. Firstly, there is a space
after the comma in the line above. The whitespace will be included in
the string to be compared. Strings which differ only by whitespace are
different. Secondly, I think these statements will be evaluated not
when the rule happens but when the makefile is parsed. (I have been
wrong about this before so it would be cool if someone else on the list
chimed in to confirm.)
The following example using the $(if) function may work as you expect.
ALL_BLOCKS := a b c d e
SOME_BLOCKS := c d
$(ALL_BLOCKS):
@echo "the target is ->$@<-"
$(if $(filter $@,$(SOME_BLOCKS)), \
@echo "yes ->$@<=>$(filter $@, $(SOME_BLOCKS))<-", \
@echo "no ->$@<=>$(filter $@, $(SOME_BLOCKS))<-" \
)
The output for 'gmake a b c d e' looks like this.
the target is ->a<-
no ->a<=><-
the target is ->b<-
no ->b<=><-
the target is ->c<-
yes ->c<=>c<-
the target is ->d<-
yes ->d<=>d<-
the target is ->e<-
no ->e<=><-
Ken
>
> @echo "yes ->$@<=>$(filter $@, $(SOME_BLOCKS))<-"
>
> else
>
> @echo "no ->$@<=>$(filter $@, $(SOME_BLOCKS))<-"
>
> endif
>
>
> Basically i am trying to check if the given letter is in a subset of
> the full list of letters.
>
>
> make d
>
> the target is ->d<-
>
> yes ->d<=>d<-
>
>
> make a
>
> the target is ->a<-
>
> yes ->a<=><-
>
>
> I have tried many variations in syntax without success. Can anyone
> explain this?
>
>
>
> thanks,
>
>
> -chuck
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make