help-make
[Top][All Lists]
Advanced

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

Re: confusing ifeq behavior


From: Paul D. Smith
Subject: Re: confusing ifeq behavior
Date: Tue, 6 Sep 2005 12:19:25 -0400

%% <address@hidden> writes:

  c> $(ALL_BLOCKS):
  c>       @echo "the target is ->$@<-"
  c> ifeq  ($@, $(filter $@, $(SOME_BLOCKS)))
  c>       @echo "yes ->$@<=>$(filter $@, $(SOME_BLOCKS))<-"
  c> else
  c>       @echo "no  ->$@<=>$(filter $@, $(SOME_BLOCKS))<-"
  c> endif

You can't do that.

Preprocessor commands like ifeq (as with the C preprocessor) are expanded
as the makefile is parsed.

Automatic variables like $@ are not valid until much later, when make
tries to execute the command script.

In this context $@ will ALWAYS be empty.


You have to either use a shell if statement to test $@, or use the $(if
...) function inside the command script.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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