summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2022-09-20 03:08:29 -0400
committerPaul Smith <psmith@gnu.org>2022-09-20 03:55:39 -0400
commita9a49199095daf5ac6f7d90bcd98b24e8e8ab39b (patch)
treec7a6b83f4cd0b66188975a759494379f6e356b43
parentd12ff78cb207027b04792c28078ba1086cddcd95 (diff)
downloadmake-git-a9a49199095daf5ac6f7d90bcd98b24e8e8ab39b.tar.gz
[SV 56301] Fail if an included makefile can't be built
Fail if a mandatory include file fails to be built even if it's built as part of a grouped target where the other include file is optional. * src/main.c (main): If a makefile doesn't build set any_failed. * tests/scripts/features/include: Add tests. * tests/scripts/options/dash-k: Stop after include build failure.
-rw-r--r--src/main.c1
-rw-r--r--tests/scripts/features/include61
-rw-r--r--tests/scripts/options/dash-k5
3 files changed, 36 insertions, 31 deletions
diff --git a/src/main.c b/src/main.c
index 91eae580..7392a432 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2499,6 +2499,7 @@ main (int argc, char **argv, char **envp)
any_remade |= (mtime != NONEXISTENT_MTIME
&& mtime != makefile_mtimes[i]);
makefile_status = MAKE_FAILURE;
+ any_failed = 1;
}
}
diff --git a/tests/scripts/features/include b/tests/scripts/features/include
index 14741609..69d67181 100644
--- a/tests/scripts/features/include
+++ b/tests/scripts/features/include
@@ -8,16 +8,11 @@ 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;
+create_file('incl.mk', "ANOTHER: ; \@echo This is another included makefile\n");
-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.
+run_make_test(qq!#Extra space at the end of the following file name
+include incl.mk ! . q!
+all: ; @echo There should be no errors for this makefile.
-include nonexistent.mk
-include nonexistent.mk
@@ -27,27 +22,12 @@ sinclude nonexistent-2.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));
+!,
+ "all", "There should be no errors for this makefile.\n");
-&run_make_with_options($makefile, "ANOTHER", &get_logfile);
-$answer = "This is another included makefile\n";
-&compare_output($answer, &get_logfile(1));
+run_make_test(undef, "ANOTHER", "This is another included makefile\n");
-$makefile = undef;
+unlink('incl.mk');
# 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
@@ -443,6 +423,31 @@ hello.mk: ; echo 'FOO=bar' > $@
!,
'', 'FOO=');
+# SV 56301 Verify pattern rules creating optional includes.
+# -k shouldn't matter when creating include files.
+
+run_make_test(q!
+all:; @echo hello
+-include inc_a.mk
+include inc_b.mk
+%_a.mk %_b.mk:; exit 1
+!,
+ '', "exit 1\n#MAKEFILE#:4: Failed to remake makefile 'inc_b.mk'.\n", 512);
+
+run_make_test(undef, '-k', "exit 1\n#MAKEFILE#:4: Failed to remake makefile 'inc_b.mk'.\n", 512);
+
+# It seems wrong to me that this gives a different error message, but at
+# least it doesn't keep going.
+run_make_test(q!
+all:; @echo hello
+include inc_a.mk
+-include inc_b.mk
+%_a.mk %_b.mk:; exit 1
+!,
+ '', "exit 1\n#MAKEFILE#:3: inc_a.mk: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: inc_a.mk] Error 1\n", 512);
+
+run_make_test(undef, '-k', "exit 1\n#MAKEFILE#:3: inc_a.mk: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: inc_a.mk] Error 1\n#MAKEFILE#:3: Failed to remake makefile 'inc_a.mk'.\n", 512);
+
# Check the default makefiles... this requires us to invoke make with no
# arguments. Also check MAKEFILES
diff --git a/tests/scripts/options/dash-k b/tests/scripts/options/dash-k
index 323dff60..4bd68f03 100644
--- a/tests/scripts/options/dash-k
+++ b/tests/scripts/options/dash-k
@@ -103,13 +103,12 @@ $make_name: Target 'all' not remade because of errors.\n";
if (defined $ERR_no_such_file) {
run_make_test('all: ; @echo hi
include ifile
-ifile: no-such-file; @false
+ifile: no-such-file; exit 1
',
'-k',
"#MAKEFILE#:2: ifile: $ERR_no_such_file
#MAKE#: *** No rule to make target 'no-such-file', needed by 'ifile'.
-#MAKEFILE#:2: Failed to remake makefile 'ifile'.
-hi\n",
+#MAKEFILE#:2: Failed to remake makefile 'ifile'.\n",
512);
}