Makefile: add .DELETE_ON_ERROR

Adds the special recipe .DELETE_ON_ERROR. As per the GNU make
documentation:

 .DELETE_ON_ERROR

 If .DELETE_ON_ERROR is mentioned as a target anywhere in the
 makefile, then make will delete the target of a rule if it has
 changed and its recipe exits with a nonzero exit status, just as it
 does when it receives a signal.
 [...]
 This is almost always what you want make to do, but it is not
 historical practice; so for compatibility, you must explicitly
 request it.

Signed-off-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/Makefile b/Makefile
index a41218c..474407e 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,10 @@
 # (we include many *.cmd and *.d files).
 unexport MAKEFILE_LIST
 
+# Automatically delete corrupt targets (file updated but recipe exits with a
+# nonzero status). Useful since a few recipes use shell redirection.
+.DELETE_ON_ERROR:
+
 include mk/checkconf.mk
 
 .PHONY: all