is reinvoked. We create a rule to rebuild the makefile from a temp
file, then touch the temp file to make it newer than the makefile.";
-$makefile2 = &get_tmpfile;
-$makefile_orig = &get_tmpfile;
+$omkfile = $makefile;
-open(MAKEFILE,"> $makefile");
+&utouch(-600, 'incl.mk');
+# For some reason if we don't do this then the test fails for systems
+# with sub-second timestamps, maybe + NFS? Not sure.
+&utouch(-1, 'incl-1.mk');
-print MAKEFILE <<EOM;
+run_make_test('
+all: ; @echo running rules.
-all: ; \@echo 'running rules.'
+#MAKEFILE# incl.mk: incl-1.mk
+ @echo rebuilding $@
+ @echo >> $@
-$makefile $makefile2: $makefile_orig
- \@echo 'rebuilding \$\@.'
- \@echo >> \$\@
+include incl.mk',
+ '', "rebuilding incl.mk\nrunning rules.\n");
-include $makefile2
+# Make sure updating the makefile itself also works
-EOM
+&utouch(-600, $omkfile);
-close(MAKEFILE);
+run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
-&utouch(-10, $makefile, $makefile2);
-&touch($makefile_orig);
+&rmfiles('incl.mk', 'incl-1.mk');
-&run_make_with_options($makefile, "", &get_logfile, 0);
-
-# Create the answer to what should be produced by this Makefile
-
-$answer = "rebuilding $makefile2.\nrebuilding $makefile.\nrunning rules.\n";
-
-&compare_output($answer,&get_logfile(1))
- && unlink "$makefile_orig";
# In this test we create an included file that's out-of-date, but then
# the rule doesn't update it. Make shouldn't re-exec.
-$makefile3 = &get_tmpfile;
+&utouch(-600, 'b','a');
+#&utouch(-10, 'a');
+&touch('c');
-open(MAKEFILE, "> $makefile3");
-print MAKEFILE <<'EOM';
+run_make_test('
SHELL = /bin/sh
all: ; @echo hello
c: ; echo >> $@
-include $(F)
-EOM
-
-close(MAKEFILE);
-
-&utouch(-20, 'b','a');
-#&utouch(-10, 'a');
-&touch('c');
-
-# First try with the file that's not updated "once removed" from the
-# file we're including.
-
-&run_make_with_options($makefile3, "F=a", &get_logfile, 0);
-
-$answer = "[ -f b ] || echo >> b\nhello\n";
-&compare_output($answer,&get_logfile(1));
+include $(F)',
+ 'F=a', "[ -f b ] || echo >> b\nhello\n");
# Now try with the file we're not updating being the actual file we're
# including: this and the previous one test different parts of the code.
-&run_make_with_options($makefile3, "F=b", &get_logfile, 0);
-
-$answer = "[ -f b ] || echo >> b\nhello\n";
-&compare_output($answer,&get_logfile(1));
+run_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n")
-unlink('a','b','c');
+&rmfiles('a','b','c');
# This tells the test driver that the perl test script executed properly.
1;
run_make_test('
a.x: b.x
-a.x b.x: ; touch $@
+a.x b.x: ; echo >> $@
',
- '', "touch b.x\ntouch a.x");
+ '', "echo >> b.x\necho >> a.x");
# Run it again: nothing should happen
# Now run it with -W b.x: should rebuild a.x
-run_make_test(undef, '-W b.x', 'touch a.x');
+run_make_test(undef, '-W b.x', 'echo >> 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');
+run_make_test(undef, '-W b.x', 'echo >> a.x');
# Clean up
foo.x: bar.x
@echo "\$$(info restarts=\$$(MAKE_RESTARTS))" > $@
@echo "touch $@"
-bar.x: ; touch $@
+bar.x: ; echo >> $@
baz.x: bar.x ; @echo "touch $@"
',
'', '#MAKEFILE#:3: foo.x: No such file or directory
-touch bar.x
+echo >> bar.x
touch foo.x
restarts=1
touch baz.x');
# Now run with -W bar.x
# Tweak foo.x's timestamp so the update will change it.
-utouch(1000, 'foo.x');
+&utouch(1000, 'foo.x');
run_make_test(undef, '-W bar.x', "restarts=\ntouch foo.x\nrestarts=1\ntouch baz.x");