help-make
[Top][All Lists]
Advanced

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

Re: do PHONY targets guarantee an order on dependency processing?


From: Paul D. Smith
Subject: Re: do PHONY targets guarantee an order on dependency processing?
Date: Sun, 12 Feb 2006 09:29:25 -0500

%% "Robert P. J. Day" <address@hidden> writes:

  >> If you run make without -j, then prerequisites are guaranteed to be
  >> updated in the order in which they appear.

  rpjd> really?  i could swear that i've seen *numerous* postings here
  rpjd> stating that make doesn't guarantee the processing order of a
  rpjd> rule's prerequisites.

That's just shorthand for saying you shouldn't rely on it, because
sooner or later someone will want to run your build with -j, and as soon
as that happens you really can't tell which rules will run in what
order, unless you have declared proper prerequisite information.

Sometimes it's easier to just say you can't rely on it than it is to go
through all the details for the 23rd time.  However, most times people
do say something like, "it's not guaranteed if you want to use parallel
builds".

  rpjd> and even checking the web is guaranteed to produce confilcting
  rpjd> information.

  rpjd> for instance,
  rpjd> http://www.linuxdevcenter.com/pub/a/linux/2002/01/31/make_intro.html
  rpjd> states:

  rpjd> "Make can run the prerequisites in any order."  [By "run," i assume
  rpjd> the author means "process."]

That's incorrect (unless there is some other context to it; I didn't check
the link), but it's well-intentioned.

You WILL write better makefiles if you don't assume any order on
processing of the prerequisites.

  rpjd> yet here, http://www.opengroup.org/onlinepubs/007908799/xcu/make.html,
  rpjd> you read:

  rpjd> "The make utility treats all prerequisites as targets themselves and
  rpjd> recursively ensures that they are up-to-date, processing them in the
  rpjd> order in which they appear in the rule."

This is correct.

  rpjd>   i'm confused.

The POSIX standard is, obviously, correct.

However, the POSIX standard does not tell you what happens with -j
because -j is a non-standard flag.

-- 
-------------------------------------------------------------------------------
 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




reply via email to

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