1

具体来说,我正在考虑删除剩余文件的“干净”规则。

files=file1 file2
clean:
    rm -f $(files)
file1: file1dependancy.o

我怎样才能自动清洁rm -f file1dependancy.o,甚至可能吗?

4

1 回答 1

1

通常,makefile 的结构如下所示:

RM_F  = rm -f
FILES = file1 file2

all:   ${FILES}

FILE1.o = file1dependency.o

file1: ${FILE1.o}
    ...build command mentioning ${FILE1.o}...

FILE2.o = file2.dependency.o

file2: ${FILE2.o}
    ...build command mentioning ${FILE2.o}...

clean:
    ${RM_F} ${FILE1.o} ${FILE2.o} ${FILES|

根据您的版本make,“所有依赖项”可能有一个宏;不过,它不在POSIX make

于 2012-09-26T14:43:50.237 回答