English 中文(简体)
• 用方言做file(法定规则)
原标题:Makefile wildcard (static rule?) with phony

我刚刚开始真正 gr清做的神经工作。 然而,我不理解为什么要做以下工作:

test%: test%.foo
     @echo $@
     @echo $<

all: test1 test2

.PHONY: all test1 test2

预期行为:

$ make
test1
test1.foo
test2
test2.foo
# 1,2 Order not important

然而,我知道:

$ make
make: Nothing to be done for `all .

("make all", "make test1", etc make no difference).

谁能解释为什么执行《纽约标准规则》?

最佳回答

Excerpt from the GNU make manual.

Since it knows that phony targets do not name actual files that could be remade from other files, make skips the implicit rule search for phony targets (see section Using Implicit Rules). This is why declaring a target phony is good for performance, even if you are not worried about the actual file existing.

这意味着,作为<条码>测试1和<条码>测试2的目标,不为之寻求默示规则。 即使你使用的更准确的称号为tern Rules,所有模式规则都是默示规则。

问题回答

暂无回答




相关问题
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 ...

热门标签