From bc5748e31f269cfeebe1686718fc4c03a5de277e Mon Sep 17 00:00:00 2001 From: Max Khon Date: Fri, 20 Apr 2007 06:25:45 +0000 Subject: When remaking makefiles check that mtime has actually changed. This fixes infinite restart in the following case: Makefile: foo foo: bar do-something Unlike GNU make, BSD make considers "Makefile" node as remade even if "foo" is up-to-date and was not actually rebuilt. GNU make does not consider nodes without commands as remade if child nodes were not actually rebuilt. Most probably, more proper fix would be to bring BSD make behaviour in-line with GNU make but this would be more intrusive change. --- usr.bin/make/main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 8eceedfae4de..e575ff2f8797 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -704,6 +704,7 @@ Remake_Makefiles(void) Boolean saveTouchFlag = touchFlag; Boolean saveQueryFlag = queryFlag; Boolean saveNoExecute = noExecute; + int mtime; /* * Create node @@ -767,6 +768,7 @@ Remake_Makefiles(void) /* * Check and remake the makefile */ + mtime = Dir_MTime(gn); Compat_Make(gn, gn); /* @@ -785,9 +787,18 @@ Remake_Makefiles(void) * ABORTED gn was not remade because one of its inferiors * could not be made due to errors. */ - if (gn->made == MADE) - remade_cnt++; - else if (gn->made == ERROR) + if (gn->made == MADE) { + if (mtime != Dir_MTime(gn)) { + DEBUGF(MAKE, + ("%s updated (%d -> %d).\n", + gn->name, mtime, gn->mtime)); + remade_cnt++; + } else { + DEBUGF(MAKE, + ("%s not updated: skipping restart.\n", + gn->name)); + } + } else if (gn->made == ERROR) error_cnt++; else if (gn->made == ABORTED) { printf("`%s' not remade because of errors.\n", -- cgit v1.3