I've got a slightly hackish makefile for running tests:
### Run the tests
tests := tests/test1 tests/test2 ...
test: $(tests)
$(tests): %: %.c
gcc -o $@ $(testflags) $<
$@
It works, but it makes Make do something I've never seen it do before. My test is currently broken, and causes a bus error. Make gives the following output:
gcc -o tests/test1 [flags blah blah] tests/test1.c
tests/test1
make: *** [tests/test1] Bus error
make: *** Deleting file `tests/test1'
I'm curious about the last line. I've never seen Make do that before. Why does Make delete the compiled test?
Note: I edited this example pretty heavily to make it simpler. I might have introduced some mistakes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…