English 中文(简体)
Parallel building with gnumake and prerequisites
原标题:

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!

最佳回答

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?

问题回答

暂无回答




相关问题
makefile: how to show line numbers for debugging?

Is there a way to have make display the line number where it declares an error? The -d switch doesn t seem to cut it. Updated: Example output: Reaping winning child 0x08aa8648 PID 9381 /bin/sh: ...

What is the reasoning behind the Makefile whitespace syntax?

I m revisiting Python after Michael Sparks s excellent walk through of Peter Norvig s Python spell checker at the SO DevDay in London. One of the points he highlighted was how clean Python is to look ...

Debugging GNU make

Is there a command line way in make to find out which of the prerequisites of a target is not updated?

How to add an all rule to this Makefile?

I want to just type make all and have the following Makefile do everything it s supposed to do: LEX = lex YACC = yacc CC = gcc calcu: y.tab.o lex.yy.o $(CC) -o calcu y.tab.o lex.yy.o -ly -lfl ...

How to discover number of *logical* cores on Mac OS X?

How can you tell, from the command line, how many cores are on the machine when you re running Mac OS X? On Linux, I use: x=$(awk /^processor/ {++n} END {print n+1} /proc/cpuinfo) It s not ...

Using extern in C doesn t work as expected

I have created two files: tunables.h #ifndef TUNABLES_H #define TUNABLES_H void tunables_load_conservative(); void tunables_load_aggressive(); extern int timer_x; #endif /*TUNABLES_H */ and ...

热门标签