1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
# -*-mode: perl-*-
$description = "Test GNU Make's auto-reinvocation feature.";
$details = "\
If the makefile or one it includes can be rebuilt then it is, and make
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.";
$omkfile = $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');
run_make_test('
all: ; @echo running rules.
#MAKEFILE# incl.mk: incl-1.mk ; @echo rebuilding $@; echo >> $@
include incl.mk',
'', "rebuilding incl.mk\nrunning rules.\n");
# Make sure updating the makefile itself also works
&utouch(-600, $omkfile);
run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
&rmfiles('incl.mk', 'incl-1.mk');
# 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.
&utouch(-600, 'b','a');
#&utouch(-10, 'a');
&touch('c');
run_make_test('
all: ; @echo hello
a : b ; echo >> $@
b : c ; test -f $@ || echo >> $@
c: ; echo >> $@
include $(F)',
'F=a', "test -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_test(undef, 'F=b', "test -f b || echo >> b\nhello\n");
&rmfiles('a','b','c');
# Ensure command line variables are preserved properly across re-exec
# Tests for Savannah bug #30723
run_make_test('
ifdef RECURSE
-include foo30723
endif
recurse: ; @$(MAKE) -f $(MAKEFILE_LIST) RECURSE=1 test
test: ; @echo F.O=$(F.O)
foo30723: ; @touch $@
',
'--no-print-directory F.O=bar', "F.O=bar\n");
unlink('foo30723');
# If ANY makefile is rebuilt then we should re-exec
run_make_test('
all: ; @echo RESTARTS=$(MAKE_RESTARTS)
m1.d: ; @echo $@; touch $@
m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
include m1.d
-include m2.d
',
'', "m1.d\nRESTARTS=1\n");
unlink('m1.d', 'm2.d');
# Same as before but be sure we get error messages for un-created makefiles
run_make_test('
all: ; @echo RESTARTS=$(MAKE_RESTARTS)
m1.d: ; @echo $@; touch $@
m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
include m1.d m2.d
', '',
# This runs afoul of https://savannah.gnu.org/bugs/?61226
0 ? "m1.d\n#MAKEFILE#:8: m2.d: $ERR_no_such_file"
: "m1.d\nRESTARTS=1",
0 ? 512 : 0);
unlink('m1.d', 'm2.d');
# sv 61226.
# This set of four cases tests two aspects of make.
#
# 1. If a rule has no prerequisites or recipe, and the target of the rule is a
# nonexistent file, then make imagines this target to have been updated
# whenever its rule is run.
#
# 2. Make does not re-execute itself in this case of imagined target.
#
# Test case 1.
# Make imagines hello.d was updated by a rule without recipe and without
# prereqs.
# This should succeed.
# Make should not re-execute itself.
run_make_test('
hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
hello.d:
include hello.d
', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
# Test case 2.
# Make imagines hello.d was updated by a rule with a recipe and without
# prereqs.
# This should succeed.
# Make should not re-execute itself.
run_make_test('
hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
hello.d:; $(info $@)
include hello.d
', '', "hello.d\nRESTARTS=\n#MAKE#: 'hello.o' is up to date.");
&touch('hello.td');
# Test case 3.
# Make imagines hello.d was updated by a rule without a recipe and with
# prereqs.
# This should succeed.
# Make should not re-execute itself.
run_make_test('
hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
hello.d: hello.td
include hello.d
', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
# Test case 4.
# Same test as three tests above, but the rule has both recipe and prereqs.
# Make should report this error.
run_make_test('
hello.o: hello.d; $(info $@)
hello.d: hello.td; $(info $@)
include hello.d
', '',
# This runs afoul of https://savannah.gnu.org/bugs/?61226
0 ? "hello.d\n#MAKEFILE#:4: hello.d: $ERR_no_such_file"
: "hello.d\nhello.o\n#MAKE#: 'hello.o' is up to date.",
0 ? 512 : 0);
unlink('hello.td');
# Test SV 62088 : make sure we don't re-invoke for stdin makefiles.
# The test framework doesn't seem to have a good way to do this.
create_file('input.mk', "all:;\$(info all)\n");
close(STDIN);
open(STDIN, "<", 'input.mk') || die "input.mk: $!\n";
run_make_test('', '-sf -', "all\n");
# This close MUST come at the end of the test!!
close(STDIN);
unlink('input.mk');
# This tells the test driver that the perl test script executed properly.
1;
|