Do: .DELETE_ON_ERROR for directory purposes
GNU Make includes a special target named .DELETE_ON_ERROR
. If included in your Makefile, Make will remove any target whose build sequence exits with a nonzero return status. This is useful so that subsequent calls to Make do not assume that the target was well-formed.
Here's a dummy example.
.DELETE_ON_ERROR:
out.dat: in.dat
touch out.dat
false
Because false
it gives a nonzero return value, the build fails and Make removes the target out.dat
. This is advertising and expected behavior. However, this behavior does not seem to persist when the target is a directory. Let's consider another dummy example.
.DELETE_ON_ERROR:
outdir/: in.dat
mkdir outdir/
false
In this case, the build will fail, but Make does not remove the directory outdir
. Is there a way I can give the Make command to do this?
source to share
No one has answered this question yet
Check out similar questions: