从makefile中的rm中排除文件

时间:2018-06-18 14:51:33

标签: makefile

我有一个像这样干净的PHONY的makefile:

.PHONY: clean

clean: clean_target 

# Remove files created by the build process.
clean_target:
    rm -rf *.mcs *.bit *.bin *.twr *.pwr *.tsi *.twx *.ncd *.pcf *.ngd *.ngc

我想排除名为“FIFO.ngc”的文件。我怎么能这样做?

感谢,

2 个答案:

答案 0 :(得分:2)

如果你正在使用GNU make,你可以这样做:

clean_target:
        rm -rf *.mcs *.bit *.bin *.twr *.pwr *.tsi *.twx *.ncd *.pcf *.ngd \
            $(filter-out FIFO.ngc,$(wildcard *.ngc))

答案 1 :(得分:0)

有点冗长,但您可以从列表中删除'* .ngc'并添加另一行:

find . -type f -name '*.ngc' -not -name 'FIFO.ngc' -delete