summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@kolpackov.net>2005-12-07 11:33:38 +0000
committerBoris Kolpackov <boris@kolpackov.net>2005-12-07 11:33:38 +0000
commited46d502a034613aed2ba9dfed1f6a5c028f0e72 (patch)
tree42b68caaa865142fbd3ebe302764cdd0b6aa676f
parentd2b0c204de1bcd8bf23b2775782c47785df6819b (diff)
downloadmake-ed46d502a034613aed2ba9dfed1f6a5c028f0e72.tar.gz
Fixed bug #14334 by propagate the change of modification time to all the
double-colon entries only if it is the last one to be updated.
-rw-r--r--ChangeLog6
-rw-r--r--remake.c32
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/scripts/features/double_colon28
4 files changed, 65 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a01c8cb..5d30cff2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-12-07 Boris Kolpackov <boris@kolpackov.net>
+
+ * remake.c (notice_finished_file): Propagate the change of
+ modification time to all the double-colon entries only if
+ it is the last one to be updated. Fixes bug #14334.
+
2005-11-17 Boris Kolpackov <boris@kolpackov.net>
* function.c (func_flavor): Implement the flavor function which
diff --git a/remake.c b/remake.c
index 750a80c2..0795af3b 100644
--- a/remake.c
+++ b/remake.c
@@ -841,7 +841,6 @@ notice_finished_file (struct file *file)
if ((ran && !file->phony) || touched)
{
- struct file *f;
int i = 0;
/* If -n, -t, or -q and all the commands are recursive, we ran them so
@@ -861,11 +860,34 @@ notice_finished_file (struct file *file)
i = 1;
file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME;
+ }
- /* Propagate the change of modification time to all the double-colon
- entries for this file. */
- for (f = file->double_colon; f != 0; f = f->prev)
- f->last_mtime = file->last_mtime;
+ if (file->double_colon)
+ {
+ /* If this is a double colon rule and it is the last one to be
+ updated, propagate the change of modification time to all the
+ double-colon entries for this file.
+
+ We do it on the last update because it is important to handle
+ individual entries as separate rules with separate timestamps
+ while they are treated as targets and then as one rule with the
+ unified timestamp when they are considered as a prerequisite
+ of some target. */
+
+ struct file *f;
+ FILE_TIMESTAMP max_mtime = file->last_mtime;
+
+ /* Check that all rules were updated and at the same time find
+ the max timestamp. We assume UNKNOWN_MTIME is newer then
+ any other value. */
+ for (f = file->double_colon; f != 0 && f->updated; f = f->prev)
+ if (max_mtime != UNKNOWN_MTIME
+ && (f->last_mtime == UNKNOWN_MTIME || f->last_mtime > max_mtime))
+ max_mtime = f->last_mtime;
+
+ if (f == 0)
+ for (f = file->double_colon; f != 0; f = f->prev)
+ f->last_mtime = max_mtime;
}
if (ran && file->update_status != -1)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 01aecc60..93cac874 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-07 Boris Kolpackov <boris@kolpackov.net>
+
+ * scripts/features/double_colon: Add a test for bug #14334.
+
2005-11-17 Boris Kolpackov <boris@kolpackov.net>
* scripts/functions/flavor: Add a test for the flavor function.
diff --git a/tests/scripts/features/double_colon b/tests/scripts/features/double_colon
index 082b815a..cad605db 100644
--- a/tests/scripts/features/double_colon
+++ b/tests/scripts/features/double_colon
@@ -124,4 +124,32 @@ $answer = "ok\n$make_name: Circular d <- d dependency dropped.\noops\n";
unlink('foo','f1.h','f2.h');
+
+# TEST 9: make sure all rules in s double colon family get executed
+# (Savannah bug #14334).
+#
+
+&touch('one');
+&touch('two');
+
+run_make_test('
+.PHONY: all
+all: result
+
+result:: one
+ @echo $^ >>$@
+ @echo $^
+
+result:: two
+ @echo $^ >>$@
+ @echo $^
+
+',
+'',
+'one
+two');
+
+unlink('result','one','two');
+
+# This tells the test driver that the perl test script executed properly.
1;