Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

gnu make - Order of processing components in makefile

In a makefile, the dependency line is of the form -

abc: x y z

All three of the components (x,y,z) are themselves targets in dependency lines further down in the makefile.

If make abc is invoked, in what order will the three targets x,y,z be executed?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

By default, the order of execution is the same as specified in the prerequisites list, unless there are any dependencies defined between these prerequisites.

abc: x y z

The order is x y z.

abc: x y z
y : z

The order would be x z y.

But ideally, you should design your Makefiles so that it wouldn't rely on the order in which prerequisites are specified. That is, if y should be executed after z, there must be a y : z dependence.

And keep in mind that GNU Make can execute some recipes in parallel, see Mat's answer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...