[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: non-existent prerequisite w/ empty rule makes target out of date
From: |
Paul D. Smith |
Subject: |
Re: non-existent prerequisite w/ empty rule makes target out of date |
Date: |
Tue, 24 Jun 2003 20:02:17 -0400 |
%% gk <address@hidden> writes:
g> I have discovered a behavior that seems a bit odd; would appreciate
g> thoughts on this:
g> * a rule with prerequisite file that doesn't exist: 'afile'
g> * an empty rule for 'afile'
g> => target is never considered 'up to date'
Yes.
g> It would seem to me that, since an empty rule is defined for
g> 'afile', make should know that, since this prerequisite file does
g> not exist and CANNOT be created, it cannot possibly make the target
g> out of date, yet it does.
Yes. Make in theory doesn't know _anything_ about your command script.
The fact that your script is empty and so doesn't do anything is not
within make's approved sphere of knowledge. You have a target, you
defined a command script for it, make assumes that the script builds the
target.
GNU make performs various simplifying assumptions as a performance
enhancement, to avoid useless shell invocations, but this is only a
performance enhancement and cannot change the behavior of make
(according to the POSIX spec).
Finally, this is the traditional method of forcing rules to always be
rebuilt: most makes don't have a .PHONY special target, so they do this:
foo: FORCE
FORCE: ;
and foo will always be rebuilt. This cannot be changed: there is
decades of history behind it.
g> I want the prerequisite file to affect building target, only if it
g> exists; otherwise target should be considered up to date.
g> How best to achieve this?
You can't.
See Bug (enhancement request) #109 at the GNU make project page on
Savannah.
--
-------------------------------------------------------------------------------
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