help-gnu-utils
[Top][All Lists]
Advanced

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

Re: ifeq in gmake


From: Paul D. Smith
Subject: Re: ifeq in gmake
Date: 02 Apr 2006 17:43:15 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

%% "atteson" <address@hidden> writes:

  a> Can someone explain why gmake outputs "goodbye" rather than "hello"
  a> with the following test makefile:

  a> %.a : b
  a> ifeq ($@,"a.a")
  a>     echo "hello"
  a> else
  a>     echo "goodbye"
  a> endif

Because, ifeq etc. are evaluated as make is reading in the makefile
(even if they seem to appear in a "rule context": ONLY lines beginning
with TAB are considered command scripts and passed to the shell.

On the other hand, automatic variables like $@ are set only when make is
trying to build the rules long after the makefiles have been read in.

So, $@ is always empty when you evaluate that ifeq.

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