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
|
# -*-mode: perl; rm-trailing-spaces: nil-*-
$description = "Test various forms of the GNU make 'include' command.";
$details = "\
Test include, -include, sinclude and various regressions involving them.
Test extra whitespace at the end of the include, multiple -includes and
sincludes (should not give an error) and make sure that errors are reported
for targets that were also -included.";
$makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile");
# The contents of the Makefile ...
print MAKEFILE <<EOF;
\#Extra space at the end of the following file name
include $makefile2
all: ; \@echo There should be no errors for this makefile.
-include nonexistent.mk
-include nonexistent.mk
sinclude nonexistent.mk
sinclude nonexistent-2.mk
-include makeit.mk
sinclude makeit.mk
error: makeit.mk
EOF
close(MAKEFILE);
open(MAKEFILE,"> $makefile2");
print MAKEFILE "ANOTHER: ; \@echo This is another included makefile\n";
close(MAKEFILE);
# Create the answer to what should be produced by this Makefile
&run_make_with_options($makefile, "all", &get_logfile);
$answer = "There should be no errors for this makefile.\n";
&compare_output($answer, &get_logfile(1));
&run_make_with_options($makefile, "ANOTHER", &get_logfile);
$answer = "This is another included makefile\n";
&compare_output($answer, &get_logfile(1));
$makefile = undef;
# Try to build the "error" target; this will fail since we don't know
# how to create makeit.mk, but we should also get a message (even though
# the -include suppressed it during the makefile read phase, we should
# see one during the makefile run phase).
run_make_test
('
-include foo.mk
error: foo.mk ; @echo $@
',
'',
"#MAKE#: *** No rule to make target 'foo.mk', needed by 'error'. Stop.\n",
512
);
# Make sure that target-specific variables don't impact things. This could
# happen because a file record is created when a target-specific variable is
# set.
run_make_test
('
bar.mk: foo := baz
-include bar.mk
hello: ; @echo hello
',
'',
"hello\n"
);
# Test inheritance of dontcare flag when rebuilding makefiles.
#
run_make_test('
.PHONY: all
all: ; @:
-include foo
foo: bar; @:
', '', '');
# Make sure that we don't die when the command fails but we dontcare.
# (Savannah bug #13216).
#
run_make_test('
.PHONY: all
all:; @:
-include foo
foo: bar; @:
bar:; @exit 1
', '', '');
# Check include, sinclude, -include with no filenames.
# (Savannah bug #1761).
run_make_test('
.PHONY: all
all:; @:
include
-include
sinclude', '', '');
# Test that the diagnostics is issued even if the target has been
# tried before with the dontcare flag (direct dependency case).
#
run_make_test('
-include foo
all: bar
foo: baz
bar: baz
',
'',
"#MAKE#: *** No rule to make target 'baz', needed by 'bar'. Stop.\n",
512);
# Test that the diagnostics is issued even if the target has been
# tried before with the dontcare flag (indirect dependency case).
#
run_make_test('
-include foo
all: bar
foo: baz
bar: baz
baz: end
',
'',
"#MAKE#: *** No rule to make target 'end', needed by 'baz'. Stop.\n",
512);
# Test that the diagnostics is issued even if the target has been
# tried before with the dontcare flag (include/-include case).
#
run_make_test('
include bar
-include foo
all:
foo: baz
bar: baz
baz: end
',
'',
"#MAKEFILE#:2: bar: No such file or directory
#MAKE#: *** No rule to make target 'end', needed by 'baz'. Stop.\n",
512);
if ($all_tests) {
# Test that include of a rebuild-able file doesn't show a warning
# Savannah bug #102
run_make_test(q!
include foo
foo: ; @echo foo = bar > $@
!,
'', "#MAKE#: 'foo' is up to date.\n");
rmfiles('foo');
}
1;
|