Parallel building with gnumake and prerequisites

拈花ヽ惹草 提交于 2019-12-10 02:58:24

问题


My first question (yay!) is about gnumake and parallel builds. Here's a quick example file:

.PHONY: tool_1 tool_2 tool_3 tool_4 all tools

all: | tools

tools: | tool_2 tool_3 tool_4

tool_1:
    # commands for tool 1

tool_2: | tool_1
    # commands for tool 2

tool_3: | tool_1
    # commands for tool 3

tool_4: | tool_1
    # commands for tool 4

If I do make -j on this guy, is what I have here correct to ensure that the commands for tool_1 are executed exactly once, and before make tries to build any of tool_[234]?

What I'm looking for is to have make -j cause tool_1 to be built first, then tool_[234] to be built in parallel, but without executing the commands for tool_1 three times. I hope that makes sense. Thanks for any suggestions or ideas!


回答1:


make -j behaves exactly as you expect in your question. It does not make dependencies multiple times.

What does that pipe (|) character do in your dependency list?



来源:https://stackoverflow.com/questions/2121620/parallel-building-with-gnumake-and-prerequisites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!