如何设置Makefile来处理一个目录中的所有文件,将输出重定向到另一个目录(每个输入文件一个输出文件)?我有:
INPUTS := $(wildcard ./input/*.txt)
OUTPUTS := $(patsubst %.out,%.txt,$(wildcard ./input/*.txt))
$(OUTPUTS): $(INPUTS)
python process.py $@ > ./output/${@:%.txt=%.out}
...但是它会继续在./output中重新生成已经存在的文件。
像这样写:
INPUTS := $(wildcard ./input/*.txt)
# Create a list of all the output files you want to generate
OUTPUTS := $(patsubst ./input/%.txt,./output/%.out,$(INPUTS))
# The default is to build all the OUTPUTS files
all: $(OUTPUTS)
# Tell make how to build a single output file
./output/%.out : ./input/%.txt
python process.py $< > $@
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句