Assuming we have the rule:
a: b c d e
and b
, c
, d
and e
are independent of each other.
Is the order of making b
, c
, d
, e
defined? It seems that generally they will be made in order b
, c
, d
, e
, but may it sometimes happen, that the order will be different?
No, the order is not defined. That is the whole point in using declarative dependency-oriented programming: that the computer can pick the optimal evaluation order, or in fact, evaluate them even at the same time.
It depends on the type of the prerequisite. According tho the GNU Make Manual, Section 4.2:
Sure, if I use
make -j a
, they might all get built at the same time (depending on whetherb
,c
,d
, ore
in turn have other/interrelated dependencies).In the right order, based on the rules you provide. For your particular example, that could mean any one of a number of different (4! = 24, from memory) orders.
All
make
programs are free to choose the order they like as long as the dependencies are honored. If there were other rules in your example, sayc: b
, thenc
would be made beforeb
(but that isn't the case, as you point out).If you need to rely on a specific order, you'll need more rules to enforce it. Otherwise
make
can do what it pleases. The documentation for GNU Make only states how rules are processed, not the order in which dependencies within a rule are processed. The most logical order (to me, anyway) would be the order in which they're listed but that's not guaranteed.If order matters, you can selectively enforce it using recursive make. For example, suppose you don't care what order b and c are made in, as long as they're both made before d and d is made before e. Then you could write your rule as:
Be aware that depending on the complexity of d and e, this approach may do Bad Things to your build times: see Recursive Make Considered Harmful (PDF) for arguments against doing it this way.
No, you can't count on the ordering when there are no dependency relationships.