[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The explanation of order-only prerequisites is not clear
From: |
Paul Smith |
Subject: |
Re: The explanation of order-only prerequisites is not clear |
Date: |
Tue, 07 Sep 2010 08:21:13 -0400 |
On Tue, 2010-09-07 at 10:12 +0430, ali hagigat wrote:
> 1) a target is updated when it does not exist or its last modification
> time is older than its prerequisites. For order-only prerequisites,
> the same rule applies? means if a target does not exist or its last
> modification time is older than its order-only prerequisites will be
> updated(the rule of the target will be executed)?
Obviously not, since that would make order-only prerequisites exactly
the same as normal prerequisites. The documentation says (in the
section you did not quote):
[...] A normal prerequisite makes
two statements: first, it imposes an order in which recipes will be
invoked: the recipes for all prerequisites of a target will be
completed before the recipe for the target is run. Second, it imposes
a dependency relationship: if any prerequisite is newer than the
target, then the target is considered out-of-date and must be rebuilt.
Normally, this is exactly what you want: if a target's prerequisite
is updated, then the target should also be updated.
Occasionally, however, you have a situation where you want to impose
a specific ordering on the rules to be invoked _without_ forcing the
target to be updated if one of those rules is executed. In that case,
you want to define "order-only" prerequisites.
This answers exactly your question.
> 2) In the example of the make manual, there are two rules for the
> prerequisites of 'all' target, one pattern rule at the beginning and
> then $(OBJS): | $(OBJDIR). Will these rules be executed in order and
> both will be considered? or the explicit rule will be evaluated first?
The second one does not have a recipe. It just adds prerequisites to
existing rules.
There is only one recipe defined for each .o, so that's the recipe that
will be executed. It's the same as writing:
foo.o: foo.c
$(CC) $(CFLAGS) -o $@ -c $<
foo.o: foo.h
foo.o: bar.h
> 3) After reading the manual one can not understand whether files
> objdir/foo.o, objdir/bar.o and objdir/baz.o will be updated(if objdir
> directory already does not exist) or the command $(COMPILE.c)
> $(OUTPUT_OPTION) $< will be executed at last?
Sorry you didn't understand. See above.
> 4) If objdir exists, what that makefile will do?
The same thing as make would do for any other target. There's nothing
special here about the TARGET objdir.
> 5) if objdir does not exist but object files exist, will $(OBJDIR):
> ;mkdir $(OBJDIR) be executed?
How can the object files exist if the directory doesn't exist? The
files are IN the directory. You're just being ridiculous now.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist