1

假设我有以下内容:

myfile.xyz: myfile.abc
        mycommand

.SUFFIXES:
.SUFFIXES: .xyz .abc

.abc.xyz:
        flip -e abc "$<" > "logs/$*.log"

现在假设我想mycommand成为一个自定义规则(就像现在一样),但让后缀规则在之后(或之前)运行。也就是说,我不希望我的自定义规则替换后缀规则。

4

1 回答 1

2

你想做的事情在 gnu make 中是不可能的。有双冒号规则允许一个目标使用多个配方,但它们不适用于后缀规则或模式规则。有关更多信息,请参阅有关双冒号规则的 make 手册

这是一种解决方法:

.SUFFIXES:           # Delete the default suffixes
.SUFFIXES: .xyz .abc # Define our suffix list

.abc.xyz: 
        flip -e abc "$<" > "logs/$*.log"
        if [ myfile.abc = "$<" ]; then mycommand; fi

这是使用模式规则而不是后缀规则的相同生成文件:

%.xyz: %.abc
        flip -e abc "$<" > "logs/$*.log"
        if [ myfile.abc = "$<" ]; then mycommand; fi

有关更多信息,请参阅有关模式规则和老式后缀规则的make 手册

于 2013-08-27T21:23:11.070 回答