help-make
[Top][All Lists]
Advanced

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

Re: Prerequisites processing order


From: Paul D. Smith
Subject: Re: Prerequisites processing order
Date: Fri, 1 Jul 2005 07:27:25 -0400

%% "Angel Tsankov" <address@hidden> writes:

  at> Does make process prerequisites in a specified order? If so, what
  at> is it?

Make always processes prerequisites in the order they appear in the
prerequisites list, with one exception: the prerequisites in the rule
containing the command script for that target are processed first,
regardless of the order in which they appear.

For example, this makefile:

    all: one two
    all: three four

    one two three four: ; @echo $@

will always print:

    one
    two
    three
    four

But this one:

    all: one two
    all: three four; @echo "$@: $^"

    one two three four: ; @echo $@

will always print:

    three
    four
    one
    two
    all: three four one two


This is guaranteed.  HOWEVER!  There is another twist here.  If you run
make with the -j option, to run jobs in parallel, then although make
still walks the prerequisites list in this order it will invoke
"sibling" prerequisites at the same time.  This can mean (depending on
the scheduler of your operating system, and/or the relative amount of
time it takes to build various prerequisites, they can complete in a
different order.

If you want to use -j you MUST declare all dependency relationships and
not rely on any ordering implicit in the makefile.

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