[Top][All Lists]

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

Re: Question on ifeq ()

From: Paul D. Smith
Subject: Re: Question on ifeq ()
Date: Mon, 29 Aug 2005 09:39:22 -0400

%% Bhaskar G <address@hidden> writes:

  bg> I have a simple makefile as below. Even though the $(STATUS) value is 1 
  bg> the ifeq doesnot gothrough this condition. I am using Gmake 3.80
  bg> on linux. 

  bg> all:
  bg>         $(eval STATUS := $(shell ls blahblah> nul 2>&1 ;echo $$?))
  bg>         @echo $(STATUS)
  bg> ifeq ($(strip $(STATUS)),1) 
  bg>         @echo "FAIL"
  bg>         @echo "$(STATUS) --BG1"
  bg> else
  bg>         @echo "PASS"
  bg>         @echo "$(STATUS) --BG"
  bg> endif 

Sorry, this won't do what you expect.  You are mixing and matching make
conditionals (evaluated as the makefile is read in) with command scripts
(not evaluated until the command is invoked).

This is similar to trying to check a C runtime variable in a
preprocessor #ifdef; it can't work.  The #ifdef is parsed as the source
is read in and controls what the parser sees and what is compiled, while
the runtime variable is not evaluated until the program is run.

Make conditionals work the same way.

The most critical thing to keep in mind when writing makefiles is when
things are evaluated.  If you don't have a solid foundation in that
you'll forever be running into issues and misunderstandings.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]