我需要制作一个生成文件,将我的书面命令 grep 输出与 .out 文件进行比较。grep 搜索的输入文本文件在tests/*.test 中。
Beta 的回答非常有帮助,但我不明白为什么这个 makefile
INPUT_DIR=tests
OUTPUT_DIR=outputs
FILES=$(wildcard ${INPUT_DIR}/*.test)
TEST_LIST = ${FILES:${INPUT_DIR}/%.test=%.diff}
.PHONY: all clean distclean
all: ${TEST_LIST}
echo ${FILES}
echo ${TEST_LIST}
${TEST_LIST}: ${INPUT_DIR}/%.test ${OUTPUT_DIR}/%.out
./grep apple $< >STDOUT
diff STDOUT ${OUTPUT_DIR}/$*.out > $@
${INPUT_DIR}/%.test:
echo $@
${OUTPUT_DIR}/%.out:
echo $@
clean:
rm -f ${FILES}
使用make makefile all -n
make: Nothing to be done for `makefile'.
echo tests/%.test
echo outputs/%.out
./grep apple tests/%.test >STDOUT diff STDOUT outputs/.out > 1.diff
./grep apple tests/%.test >STDOUT diff STDOUT outputs/.out > 2.diff
./grep apple tests/%.test >STDOUT diff STDOUT outputs/.out > 3.diff
echo tests/1.test tests/2.test tests/3.test
echo 1.diff 2.diff 3.diff
并使用make makefile all
make: Nothing to be done for `makefile'.
echo tests/%.test tests/%.test
echo outputs/%.out outputs/%.out
./grep apple tests/%.test >STDOUT