* main.c (main): [SV 40234] Show correct error message.

This commit is contained in:
Paul Smith 2016-12-22 16:35:47 -05:00
parent 053d49367c
commit 0029ea8941
2 changed files with 13 additions and 5 deletions

10
main.c
View file

@ -2172,6 +2172,7 @@ main (int argc, char **argv, char **envp)
while (d != 0) while (d != 0)
{ {
struct file *f; struct file *f;
for (f = d->file->double_colon; f != NULL; f = f->prev) for (f = d->file->double_colon; f != NULL; f = f->prev)
if (f->deps == 0 && f->cmds != 0) if (f->deps == 0 && f->cmds != 0)
break; break;
@ -2296,8 +2297,6 @@ main (int argc, char **argv, char **envp)
} }
} }
} }
/* Reset this to empty so we get the right error message below. */
read_files = 0;
if (any_remade) if (any_remade)
goto re_exec; goto re_exec;
@ -2534,10 +2533,11 @@ main (int argc, char **argv, char **envp)
if (!goals) if (!goals)
{ {
if (read_files == 0) struct variable *v = lookup_variable (STRING_SIZE_TUPLE ("MAKEFILE_LIST"));
O (fatal, NILF, _("No targets specified and no makefile found")); 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. */ /* Update the goals. */

View file

@ -192,6 +192,14 @@ include inc2
rmfiles('inc1'); 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 # Include same file multiple times
run_make_test(q! run_make_test(q!