[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to force make to dynamically check rule prerequisites
From: |
Paul D. Smith |
Subject: |
Re: How to force make to dynamically check rule prerequisites |
Date: |
Fri, 3 Aug 2001 14:57:59 -0400 |
%% Joshua Redstone <address@hidden> writes:
jr> Suppose I have the following makefile with make 3.79:
jr> -----------
jr> foo: foo2 foo3
jr> cat foo2 foo3 > foo
jr> foo2:
jr> echo "Need to execute some special command to make foo2"
jr> foo3:
jr> echo "Need to execute some special command to make foo3"
jr> -----------
jr> If I execute 'make foo' in an empty directory, make will execute
jr> the command 'cat foo2 foo3 > foo' (resulting in an error because
jr> foo2 and foo3 doen't exist).
jr> Is there any way to cause make to fire exactly those set of rules
jr> whose prerequisites have been satisfied?
>From make's point of view, the prerequisites _HAVE_ been satisfied.
You said it needed to build foo2 and foo3, and it found the rules that
you said would do that, and dutifully ran them. As far as make is
concerned those files now exist and are up-to-date. If those rules
don't do what you said they would and then you later assume they did,
well... :)
What you ask cannot be made standard behavior, since there are _many_
makefiles out there that expect the current behavior. I'd venture to
say well over half depend on it in some form.
This would have to be new behavior, and it would have to use a new make
syntax of some kind to specify.
All in all, it seems simpler to merely change your rules to avoid the
error, something like this:
foo: foo2 foo3
[ ! -f foo2 -o ! -f foo3 ] || cat foo2 foo3 > foo
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist