summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--main.c18
-rw-r--r--tests/ChangeLog2
-rw-r--r--tests/scripts/options/dash-W57
4 files changed, 77 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 648e502..8e53a64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,10 @@
(main): When checking makefiles, only set always_make_flag if
always_make_set is set AND the restarts flag is 0. When building
normal targets, set it IFF always_make_set is set.
+ (main): Avoid infinite recursion with -W, too: only set what-if
+ files to NEW before we check makefiles if we've never restarted
+ before. If we have restarted, set what-if files to NEW _after_ we
+ check makefiles.
2005-06-17 Paul D. Smith <psmith@gnu.org>
diff --git a/main.c b/main.c
index 0be958d..cd58a49 100644
--- a/main.c
+++ b/main.c
@@ -1772,9 +1772,9 @@ main (int argc, char **argv, char **envp)
build_vpath_lists ();
- /* Mark files given with -o flags as very old
- and as having been updated already, and files given with -W flags as
- brand new (time-stamp as far as possible into the future). */
+ /* Mark files given with -o flags as very old and as having been updated
+ already, and files given with -W flags as brand new (time-stamp as far
+ as possible into the future). If restarts is set we'll do -W later. */
if (old_files != 0)
for (p = old_files->list; *p != 0; ++p)
@@ -1786,7 +1786,7 @@ main (int argc, char **argv, char **envp)
f->command_state = cs_finished;
}
- if (new_files != 0)
+ if (!restarts && new_files != 0)
{
for (p = new_files->list; *p != 0; ++p)
{
@@ -2117,6 +2117,16 @@ main (int argc, char **argv, char **envp)
/* Set always_make_flag if -B was given. */
always_make_flag = always_make_set;
+ /* If restarts is set we haven't set up -W files yet, so do that now. */
+ if (restarts && new_files != 0)
+ {
+ for (p = new_files->list; *p != 0; ++p)
+ {
+ f = enter_command_line_file (*p);
+ f->last_mtime = f->mtime_before_update = NEW_MTIME;
+ }
+ }
+
/* If there is a temp file from reading a makefile from stdin, get rid of
it now. */
if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 90fbf7d..be5169b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -4,6 +4,8 @@
MAKE_RESTARTS variable.
* scripts/options/dash-B: Test re-exec doesn't loop infinitely.
Tests fix for Savannah bug #7566.
+ * scripts/options/dash-W: New file: test the -W flag, including
+ re-exec infinite looping.
2005-06-12 Paul D. Smith <psmith@gnu.org>
diff --git a/tests/scripts/options/dash-W b/tests/scripts/options/dash-W
new file mode 100644
index 0000000..9a12d9a
--- /dev/null
+++ b/tests/scripts/options/dash-W
@@ -0,0 +1,57 @@
+# -*-perl-*-
+
+$description = "Test make -W (what if) option.\n";
+
+# Basic build
+
+run_make_test('
+a.x: b.x
+a.x b.x: ; touch $@
+',
+ '', "touch b.x\ntouch a.x");
+
+# Run it again: nothing should happen
+
+run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
+
+# Now run it with -W b.x: should rebuild a.x
+
+run_make_test(undef, '-W b.x', 'touch a.x');
+
+# Put the timestamp for a.x into the future; it should still be remade.
+
+utouch(1000, 'a.x');
+run_make_test(undef, '', "#MAKE#: `a.x' is up to date.");
+run_make_test(undef, '-W b.x', 'touch a.x');
+
+# Clean up
+
+rmfiles('a.x', 'b.x');
+
+# Test -W with the re-exec feature: we don't want to re-exec forever
+# Savannah bug # 7566
+
+# First set it up with a normal build
+
+run_make_test('
+all: baz.x ; @:
+include foo.x
+foo.x: bar.x
+ @echo "\$$(info restarts=\$$(MAKE_RESTARTS))" > $@
+ @echo "touch $@"
+bar.x: ; touch $@
+baz.x: bar.x ; @echo "touch $@"
+',
+ '', '#MAKEFILE#:3: foo.x: No such file or directory
+touch bar.x
+touch foo.x
+restarts=1
+touch baz.x');
+
+# Now run with -W bar.x
+
+run_make_test(undef, '-W bar.x', "restarts=\ntouch foo.x\nrestarts=1\ntouch baz.x");
+
+rmfiles('foo.x', 'bar.x');
+
+1;