3 $description = "Test GNU make's auto-reinvocation feature.";
6 If the makefile or one it includes can be rebuilt then it is, and make
7 is reinvoked. We create a rule to rebuild the makefile from a temp
8 file, then touch the temp file to make it newer than the makefile.";
12 &utouch(-600, 'incl.mk');
13 # For some reason if we don't do this then the test fails for systems
14 # with sub-second timestamps, maybe + NFS? Not sure.
15 &utouch(-1, 'incl-1.mk');
18 all: ; @echo running rules.
20 #MAKEFILE# incl.mk: incl-1.mk ; @echo rebuilding $@; echo >> $@
23 '', "rebuilding incl.mk\nrunning rules.\n");
25 # Make sure updating the makefile itself also works
27 &utouch(-600, $omkfile);
29 run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
31 &rmfiles('incl.mk', 'incl-1.mk');
34 # In this test we create an included file that's out-of-date, but then
35 # the rule doesn't update it. Make shouldn't re-exec.
37 &utouch(-600, 'b','a');
46 b : c ; test -f $@ || echo >> $@
51 'F=a', "test -f b || echo >> b\nhello\n");
53 # Now try with the file we're not updating being the actual file we're
54 # including: this and the previous one test different parts of the code.
56 run_make_test(undef, 'F=b', "test -f b || echo >> b\nhello\n");
58 &rmfiles('a','b','c');
60 # Ensure command line variables are preserved properly across re-exec
61 # Tests for Savannah bug #30723
67 recurse: ; @$(MAKE) -f $(MAKEFILE_LIST) RECURSE=1 test
68 test: ; @echo F.O=$(F.O)
71 '--no-print-directory F.O=bar', "F.O=bar\n");
75 # If ANY makefile is rebuilt then we should re-exec
78 all: ; @echo RESTARTS=$(MAKE_RESTARTS)
80 m1.d: ; @echo $@; touch $@
82 m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
87 '', "m1.d\nRESTARTS=1\n");
89 unlink('m1.d', 'm2.d');
91 # Same as before but be sure we get error messages for un-created makefiles
93 all: ; @echo RESTARTS=$(MAKE_RESTARTS)
95 m1.d: ; @echo $@; touch $@
97 m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
101 # This runs afoul of https://savannah.gnu.org/bugs/?61226
102 0 ? "m1.d\n#MAKEFILE#:8: m2.d: $ERR_no_such_file"
103 : "m1.d\nRESTARTS=1",
106 unlink('m1.d', 'm2.d');
109 # This set of four cases tests two aspects of make.
111 # 1. If a rule has no prerequisites or recipe, and the target of the rule is a
112 # nonexistent file, then make imagines this target to have been updated
113 # whenever its rule is run.
115 # 2. Make does not re-execute itself in this case of imagined target.
118 # Make imagines hello.d was updated by a rule without recipe and without
120 # This should succeed.
121 # Make should not re-execute itself.
123 hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
126 ', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
129 # Make imagines hello.d was updated by a rule with a recipe and without
131 # This should succeed.
132 # Make should not re-execute itself.
134 hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
137 ', '', "hello.d\nRESTARTS=\n#MAKE#: 'hello.o' is up to date.");
141 # Make imagines hello.d was updated by a rule without a recipe and with
143 # This should succeed.
144 # Make should not re-execute itself.
146 hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
149 ', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
152 # Same test as three tests above, but the rule has both recipe and prereqs.
153 # Make should report this error.
155 hello.o: hello.d; $(info $@)
156 hello.d: hello.td; $(info $@)
159 # This runs afoul of https://savannah.gnu.org/bugs/?61226
160 0 ? "hello.d\n#MAKEFILE#:4: hello.d: $ERR_no_such_file"
161 : "hello.d\nhello.o\n#MAKE#: 'hello.o' is up to date.",
166 # Test DV 62088 : make sure we don't re-invoke for stdin makefiles.
167 # The test framework doesn't seem to have a good way to do this.
169 create_file('input.mk', "all:;\$(info all)\n");
172 open(STDIN, "<", 'input.mk') || die "input.mk: $!\n";
174 run_make_test('', '-sf -', "all\n");
179 # This tells the test driver that the perl test script executed properly.