I have a directory with test inputs and outputs. I wanted make
to automatically test my program against this directory after build, for convenience. Thus I needed to somehow force the test
target of Makefile
to depend on the entire testing directory (it's called good
, because it contains valid inputs and outputs for the program)
I read this question and the accepted answer and the comments about deleted files under this answer: Makefile rule that depends on all files under a directory (including within subdirectories) And, incorporating advice from this answer & comments, I came out with this:
my@comp:~/wtfdir$ cat Makefile
test : test.sh $(shell find good)
./test.sh
my@comp:~/wtfdir$
For the sake of MCVE, test.sh
is very rudimentary:
my@comp:~/wtfdir$ cat test.sh
echo "blah"
my@comp:~/wtfdir$
However, I noticed, this behaves in a rather unexpected way:
my@comp:~/wtfdir$ ls good
test1 test1.out
my@comp:~/wtfdir$ make
./test.sh
blah
my@comp:~/wtfdir$ touch good/test1
my@comp:~/wtfdir$ make
cp good/test1 good/test1.out
./test.sh
blah
my@comp:~/wtfdir$
Why (expletive redacted) does modifying test1
cause make
to overwrite test1.out
with test1
??? I'm not a big fan of data losses, you know.
What's going on here?