模式规则有效,但后缀规则无效

时间:2018-07-22 12:05:08

标签: makefile posix gnu-make

模式规则有效:

$ ls
Makefile   hello.txt  world.txt
$ cat Makefile
all: hello.out world.out

%.out: %.txt
        cp $< $@

$ make
cp hello.txt hello.out
cp world.txt world.out

但是,当我尝试用我认为是完全等效的后缀规则替换它们时,它们不起作用:

$ ls
Makefile   hello.txt  world.txt
$ cat Makefile
.POSIX:
.SUFFIXES:
.SUFFIXES:.txt.out

all: hello.out world.out

.txt.out:
        cp $< $@

$ make
make: *** No rule to make target 'hello.out', needed by 'all'.  Stop.

我不明白为什么。

1 个答案:

答案 0 :(得分:1)

这是问题所在:

.SUFFIXES: .txt.out

它声明一个后缀.txt.out,而不是两个。您可以将其更改为此:

.SUFFIXES: .txt .out
相关问题