1999-09-14 02:03:19 +00:00
|
|
|
# -*-mode: perl; rm-trailing-spaces: nil-*-
|
|
|
|
|
2012-03-04 00:24:20 +00:00
|
|
|
$description = "Test various forms of the GNU make 'include' command.";
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2004-05-16 19:16:52 +00:00
|
|
|
$details = "\
|
|
|
|
Test include, -include, sinclude and various regressions involving them.
|
1999-09-14 02:03:19 +00:00
|
|
|
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
|
2004-09-28 18:13:55 +00:00
|
|
|
include $makefile2
|
1999-09-14 02:03:19 +00:00
|
|
|
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));
|
|
|
|
|
2004-05-16 19:16:52 +00:00
|
|
|
$makefile = undef;
|
|
|
|
|
1999-09-14 02:03:19 +00:00
|
|
|
# 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).
|
|
|
|
|
2004-05-16 19:16:52 +00:00
|
|
|
run_make_test
|
|
|
|
('
|
|
|
|
-include foo.mk
|
|
|
|
error: foo.mk ; @echo $@
|
|
|
|
',
|
|
|
|
'',
|
2012-03-04 00:24:20 +00:00
|
|
|
"#MAKE#: *** No rule to make target 'foo.mk', needed by 'error'. Stop.\n",
|
2004-05-16 19:16:52 +00:00
|
|
|
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"
|
|
|
|
);
|
2000-01-23 07:05:16 +00:00
|
|
|
|
2005-05-31 20:54:30 +00:00
|
|
|
|
2004-09-28 18:13:55 +00:00
|
|
|
# Test inheritance of dontcare flag when rebuilding makefiles.
|
|
|
|
#
|
|
|
|
run_make_test('
|
|
|
|
.PHONY: all
|
|
|
|
all: ; @:
|
|
|
|
|
|
|
|
-include foo
|
|
|
|
|
|
|
|
foo: bar; @:
|
|
|
|
', '', '');
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2005-05-31 20:54:30 +00:00
|
|
|
|
|
|
|
# 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; @:
|
|
|
|
|
2005-07-04 03:50:59 +00:00
|
|
|
bar:; @exit 1
|
2005-05-31 20:54:30 +00:00
|
|
|
', '', '');
|
|
|
|
|
2005-06-27 01:01:07 +00:00
|
|
|
# Check include, sinclude, -include with no filenames.
|
|
|
|
# (Savannah bug #1761).
|
|
|
|
|
|
|
|
run_make_test('
|
|
|
|
.PHONY: all
|
|
|
|
all:; @:
|
|
|
|
include
|
|
|
|
-include
|
|
|
|
sinclude', '', '');
|
|
|
|
|
2009-09-30 09:54:26 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
',
|
|
|
|
'',
|
2012-03-04 00:24:20 +00:00
|
|
|
"#MAKE#: *** No rule to make target 'baz', needed by 'bar'. Stop.\n",
|
2009-09-30 09:54:26 +00:00
|
|
|
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
|
|
|
|
',
|
|
|
|
'',
|
2012-03-04 00:24:20 +00:00
|
|
|
"#MAKE#: *** No rule to make target 'end', needed by 'baz'. Stop.\n",
|
2009-09-30 09:54:26 +00:00
|
|
|
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
|
2012-03-04 00:24:20 +00:00
|
|
|
#MAKE#: *** No rule to make target 'end', needed by 'baz'. Stop.\n",
|
2009-09-30 09:54:26 +00:00
|
|
|
512);
|
|
|
|
|
2009-10-03 20:08:20 +00:00
|
|
|
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 > $@
|
|
|
|
!,
|
2012-03-04 00:24:20 +00:00
|
|
|
'', "#MAKE#: 'foo' is up to date.\n");
|
2009-10-03 20:08:20 +00:00
|
|
|
rmfiles('foo');
|
|
|
|
}
|
|
|
|
|
2005-05-31 20:54:30 +00:00
|
|
|
1;
|