[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ifneq gnumake bug
From: |
Paul D. Smith |
Subject: |
Re: ifneq gnumake bug |
Date: |
Thu, 20 Nov 2003 09:55:06 -0500 |
%% Jeremy Broughton <address@hidden> writes:
jb> I have the following sample makefile, which seems to produce the
jb> following erroneous output, using the cygwin version 1.3.10:
The output is not erroneous.
jb> target1.txt target2.txt :
jb> ifneq "" "$^"
jb> @echo $^
jb> else
jb> @echo this doesn't seem empty to me: $^
jb> endif
Someone else gave the answer: I'll elaborate a little bit. It's
critically important to grasp the difference between make constructs,
like ifeq etc., and command line constructs, like the @echo ... lines.
Make constructs are evaluated as the makefile is read in. Command line
constructs are evaluated when the command is about to be run.
Automatic variables, like $^, are only set in the context of the command
scripts.
So, when the ifneq is evaluated, when the makefile is being read in, the
value of $^ is the empty string.
Later on, when make is done reading the makefiles, starts to run the
rules, and decides to rebuild "target1.txt", it will set $^ to the value
of the prerequisite then evaluate the command script, so you get the
output you see.
jb> Do you know if this is fixed in a newer cygwin release?
It will never be "fixed", because it is not a bug.
--
-------------------------------------------------------------------------------
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