Reputation: 603
i need to make a makefile which compares my written command grep output with .out file. The input text file which grep searches is in tests/*.test.
Beta's answer was very helpfull, except i cannot understand why this 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}
using 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
and using 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
Upvotes: 0
Views: 494
Reputation: 99104
Your question is unclear, but since you use the file STDOUT
as an intermediate file, and you use it for every comparison, and you use it for nothing else, I advise you to combine the rules:
%.diff: ${INPUT_DIR}/%.test ${OUTPUT_DIR}/%.out
./grep apple $< >STDOUT # Do you really have an executable called "grep"?
diff STDOUT ${OUTPUT_DIR}/$*.out > $@
Also, your all
rule doesn't do what you expect. Try this:
all:
@echo you must specify a target, e.g. outputs/foo.diff
Upvotes: 1