* main.c (main): [SV 40234] Show correct error message.
diff --git a/main.c b/main.c
index b170e8e..80c17da 100644
--- a/main.c
+++ b/main.c
@@ -2172,6 +2172,7 @@
while (d != 0)
{
struct file *f;
+
for (f = d->file->double_colon; f != NULL; f = f->prev)
if (f->deps == 0 && f->cmds != 0)
break;
@@ -2296,8 +2297,6 @@
}
}
}
- /* Reset this to empty so we get the right error message below. */
- read_files = 0;
if (any_remade)
goto re_exec;
@@ -2534,10 +2533,11 @@
if (!goals)
{
- if (read_files == 0)
- O (fatal, NILF, _("No targets specified and no makefile found"));
+ struct variable *v = lookup_variable (STRING_SIZE_TUPLE ("MAKEFILE_LIST"));
+ if (v && v->value && v->value[0] != '\0')
+ O (fatal, NILF, _("No targets"));
- O (fatal, NILF, _("No targets"));
+ O (fatal, NILF, _("No targets specified and no makefile found"));
}
/* Update the goals. */
diff --git a/tests/scripts/features/include b/tests/scripts/features/include
index f78563f..4b8bd7e 100644
--- a/tests/scripts/features/include
+++ b/tests/scripts/features/include
@@ -192,6 +192,14 @@
rmfiles('inc1');
+# No target gets correct error
+run_make_test('', '', '#MAKE#: *** No targets. Stop.', 512);
+
+# No target in included file either, still gets correct error.
+touch('inc1.mk');
+run_make_test('include inc1.mk', '', '#MAKE#: *** No targets. Stop.', 512);
+rmfiles('inc1.mk');
+
# Include same file multiple times
run_make_test(q!