]> git.pond.sub.org Git - empserver/commitdiff
Clean up dependencies after failed compile
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 25 Feb 2008 20:38:22 +0000 (21:38 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 14 Mar 2008 19:25:09 +0000 (20:25 +0100)
If gcc's preprocessor chokes, it leaves an empty dependency file
behind, and doesn't touch the object file.  If an old object file
exists, and is newer than the .c file, make will then consider the
object file up-to-date.  This can lead to nasty version errors.

Make.mk

diff --git a/Make.mk b/Make.mk
index 2508e1b727ce9e30b20051d071de929a382567ec..0acf0bafadbe60f26232ad17f14144531d2793c3 100644 (file)
--- a/Make.mk
+++ b/Make.mk
@@ -233,7 +233,12 @@ dist: dist-source dist-client dist-info
 # addition to %.o.
 ifeq ($(how_to_dep),fast)
 %.o: %.c
-       $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $<
+       $(COMPILE.c) -MT $@ -MMD -MP $(OUTPUT_OPTION) $< \
+       || { rm -f $(@:.o=.d) $@; false; }
+# Why the rm?  If gcc's preprocessor chokes, it leaves an empty
+# dependency file behind, and doesn't touch the object file.  If an
+# old object file exists, and is newer than the .c file, make will
+# then consider the object file up-to-date.
 endif
 ifeq ($(how_to_dep),depcomp)
 %.o: %.c