From adbcdf4335f8b93be58b19b7e6feeaf55340753b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 25 Feb 2008 21:38:22 +0100 Subject: [PATCH] Clean up dependencies after failed compile 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Make.mk b/Make.mk index 2508e1b7..0acf0baf 100644 --- 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