bug-make
[Top][All Lists]
Advanced

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

Re: order-only prerequisites don't behave as I'd have expected after rea


From: Philip Guenther
Subject: Re: order-only prerequisites don't behave as I'd have expected after reading the documentation
Date: Tue, 12 Jun 2012 11:31:12 -0700

On Tue, Jun 12, 2012 at 12:59 AM, Stefano Lattarini
<address@hidden> wrote:
> On 06/12/2012 02:06 AM, Philip Guenther wrote:
>> On Mon, Jun 11, 2012 at 12:53 PM, Stefano Lattarini
>> <address@hidden> wrote:
>> ...
>>> I was hoping to be able to the order-only prerequisites to enforce ordering
>>> between .PHONY targets.  At this point, I guess I should state the problem
>>> I am trying to solve rather than just the attempts I've made at solving it.
>>>
>>>   Is there an easy, scalable way to specify in a GNUmakefile that, whenever
>>>   two given targets T1 and T2 (either phony or not) are to be updated, T1's
>>>   recipe must be executed before T2's, all without declaring any dependency
>>>   of T2 on T1?  So that for example, assuming T1 and T2 are both phony:
>>>
>>>     $ make T1 # Only run T1's recipe
>>>     $ make T2 # Only run T2's recipe
>>>     $ make T2 T1 # Run T1's recipe, then T2's recipe
>>>     $ make -j8 T2 T1 # Again, run T1's recipe, then T2's recipe
>>
>> I think I would use a test on $(MAKECMDGOALS) to make T1 a
>> prerequisite of T2 if and only if T1 is a goal, say...
>>
>>      ifneq ($(filter T1,${MAKECMDGOALS}),)
>>      T2: T1
>>      endif
>>
> Not good enough; the "order dependency" I want between T1 and T2 should
> have to work also when they are updated as dependencies of other targets:
>
>    $ cat Makefile
>    all: T1 T2
>    ...
>    $ make all # Ought to work executing T1 before T2.

Given the design of make, with its lazy DAG building, what you are
asking for cannot be done automatically by make, as when it hits T2 as
a prerequisite it cannot know whether a not-yet-considered target will
end up having T1 as a prerequisite.

My gut reaction is that something in this setup is over-simplifying
things or misleading make.  If T1 needs to be done before T2 _ever_,
then why not _always_ have it as a prerequisite of T2?  Is the
.PHONYness of T1 a hack to get around some other limitation and using
some sort of timestamp file would let T1 be not-.PHONY and always be a
dependency of T2?

Whatever.  Insufficient data.  Workaround: use the MAKECMDGOALS test
previously cited but list all the targets that depend on T1 as well in
the $(filter) clause.


Philip Guenther



reply via email to

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