help-make
[Top][All Lists]
Advanced

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

Re: A question about order-only dependencies.


From: Philip Guenther
Subject: Re: A question about order-only dependencies.
Date: Sun, 7 Sep 2008 16:05:08 -0700

On Sun, Sep 7, 2008 at 3:03 PM, Evan Bigall <address@hidden> wrote:
> Consider the following rule:
>
> .phony : objs_built

(psst: ".phony" isn't special, only ".PHONY" is)


> objs_built : | $(objs)
>        @echo objs built
>
> The idea is to be able to have a phony target "objs_built", that when 
> included in a
> list of other targets could tell you when all of the objects that were going 
> to be built
> had been built.
>
> The problem is, that when make is invoked with objs_built as a target it puts 
> all of
> the $(objs) on the list of things to built.  I was expecting that because 
> $(objs) is an
> order-only dependency, of objs_built building objs_built would not imply 
> building
> objs.  I know that's a little bit backwards, but it's what I at least was 
> expecting.
>
> Does my expectation make sense?  Was I incorrect?

Your understanding of order-only prerequisites is incorrect, yes.  An
o-o prereq is the same as a normal prereq as far as the "when
something is a target, make sure all its prerequisites are up to date
first, before deciding whether it needs to actually be (re)built" part
goes.  The order-only bit just affects the second part, the "does this
target actually need to be rebuilt?" question.

So you're looking for some way to say this:
  In this make invocation, zero or more of the files a.o, b.o, c.o,
and d.o, may be
  rebuilt. Once all the ones that _will_ be rebuilt, _have_ been
rebuilt, then run this
  command.

Off-hand, I can't see any simple way to implement that.  The problem
is that make decides what to rebuild as it goes.  Indeed, with
$(eval), it's possible to add a dependency when make is already part
way through building stuff: after make has built of those files, it
can't be sure that that was the last one that it'll need to build this
run.  Only after the last target's commands have been started is that
certain.


...
>> make -r -R run_all

FYI: -R implies -r, so that can be abbreviated as "make -R run_all"


Philip Guenther




reply via email to

[Prev in Thread] Current Thread [Next in Thread]