The function is expanded to the contents of the file. The contents are
expanded verbatim except that the final newline, if any, is stripped.
+* The makefile line numbers shown by GNU make now point directly to the
+ specific line in the recipe where the failure or warning occurred.
+ Sample changes suggested by Brian Vandenberg <phantall@gmail.com>
+
* The interface to GNU make's "jobserver" is stable as documented in the
manual, for tools which may want to access it.
* The amount of parallelism can be determined by querying MAKEFLAGS, even when
the job server is enabled (previously MAKEFLAGS would always contain only
- "-j" when job server was enabled).
+ "-j", with no number, when job server was enabled).
* VMS-specific changes:
if (reading_file && reading_file->filenm)
{
char *p = alloca (strlen (reading_file->filenm)+11+4);
- sprintf (p, "%s:%lu: ", reading_file->filenm, reading_file->lineno);
+ sprintf (p, "%s:%lu: ", reading_file->filenm,
+ reading_file->lineno + reading_file->offset);
error_prefix = p;
}
else
{
const char *filenm;
unsigned long lineno;
+ unsigned long offset;
} gmk_floc;
typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv);
else
{
char *a = alloca (strlen (flocp->filenm) + 1 + 11 + 1);
- sprintf (a, "%s:%lu", flocp->filenm, flocp->lineno);
+ sprintf (a, "%s:%lu", flocp->filenm, flocp->lineno + flocp->offset);
nm = a;
}
memmove (out, in, strlen (in) + 1);
/* Finally, expand the line. */
+ cmds->fileinfo.offset = i;
lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i],
file);
}
+ cmds->fileinfo.offset = 0;
c->command_lines = lines;
/* Fetch the first command line to be run. */
{
/* There are no more lines to be expanded. */
child->command_ptr = 0;
+ child->file->cmds->fileinfo.offset = 0;
return 0;
}
else
/* Get the next line to run. */
child->command_ptr = child->command_lines[child->command_line++];
}
+
+ child->file->cmds->fileinfo.offset = child->command_line - 1;
return 1;
}
p = get_buffer (len);
if (flocp && flocp->filenm)
- sprintf (p, "%s:%lu: ", flocp->filenm, flocp->lineno);
+ sprintf (p, "%s:%lu: ", flocp->filenm, flocp->lineno + flocp->offset);
else if (makelevel == 0)
sprintf (p, "%s: ", program);
else
p = get_buffer (len);
if (flocp && flocp->filenm)
- sprintf (p, "%s:%lu: *** ", flocp->filenm, flocp->lineno);
+ sprintf (p, "%s:%lu: *** ", flocp->filenm, flocp->lineno + flocp->offset);
else if (makelevel == 0)
sprintf (p, "%s: *** ", program);
else
ebuf.floc.filenm = filename; /* Use the original file name. */
ebuf.floc.lineno = 1;
+ ebuf.floc.offset = 0;
if (ISDB (DB_VERBOSE))
{
{
ebuf.floc.filenm = NULL;
ebuf.floc.lineno = 1;
+ ebuf.floc.offset = 0;
}
curfile = reading_file;
if (filenames != 0) \
{ \
fi.lineno = tgts_started; \
+ fi.offset = 0; \
record_files (filenames, pattern, pattern_percent, depstr, \
cmds_started, commands, commands_idx, two_colon, \
prefix, &fi); \
cmds = xmalloc (sizeof (struct commands));
cmds->fileinfo.filenm = flocp->filenm;
cmds->fileinfo.lineno = cmds_started;
+ cmds->fileinfo.offset = 0;
cmds->commands = xstrndup (commands, commands_idx);
cmds->command_lines = 0;
cmds->recipe_prefix = prefix;
r->cmds = xmalloc (sizeof (struct commands));
r->cmds->fileinfo.filenm = 0;
r->cmds->fileinfo.lineno = 0;
+ r->cmds->fileinfo.offset = 0;
/* These will all be string literals, but we malloc space for them
anyway because somebody might want to free them later. */
r->cmds->commands = xstrdup (p->commands);
&compare_output($answer,&get_logfile(1));
}
+# Test that error line offset works
+
+run_make_test(q!
+all:
+ @echo hi
+ @echo there
+ @exit 1
+!,
+ '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512);
+
1;
+
+### Local Variables:
+### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
+### End:
#MAKE#[1]: Entering directory '#PWD#/foo'
foo-fail: start
foo-fail: end
-#MAKE#[1]: *** [Makefile:20: foo-fail] Error 1
+#MAKE#[1]: *** [Makefile:23: foo-fail] Error 1
#MAKE#[1]: Leaving directory '#PWD#/foo'
#MAKE#: *** [#MAKEFILE#:4: make-foo-fail] Error 2\n",
512);
\@$sleep_command 4
\@echo Ok done",
'-rR -j5', "Fail
-#MAKE#: *** [#MAKEFILE#:6: fail.1] Error 1
+#MAKE#: *** [#MAKEFILE#:8: fail.1] Error 1
#MAKE#: *** Waiting for unfinished jobs....
Fail
-#MAKE#: *** [#MAKEFILE#:6: fail.2] Error 1
+#MAKE#: *** [#MAKEFILE#:8: fail.2] Error 1
Fail
-#MAKE#: *** [#MAKEFILE#:6: fail.3] Error 1
+#MAKE#: *** [#MAKEFILE#:8: fail.3] Error 1
Ok done",
512);
# Test #4
&run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512);
-$answer = "Some stuff\n$makefile:16: *** error is definitely. Stop.\n";
+$answer = "Some stuff\n$makefile:17: *** error is definitely. Stop.\n";
&compare_output($answer,&get_logfile(1));
# Test #5
# This tells the test driver that the perl test script executed properly.
1;
-
-
-
-
-
+### Local Variables:
+### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
+### End:
all: ; @echo $$HI
','','hi');
+# Test shell errors in recipes including offset
+run_make_test('
+all:
+ @echo hi
+ $(shell ./basdfdfsed there)
+ @echo there
+',
+ '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n");
+
1;
+
+### Local Variables:
+### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
+### End:
# Test #4
&run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0);
-$answer = "Some stuff\n$makefile:14: warning is definitely\nhi\nthere\n";
+$answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n";
&compare_output($answer,&get_logfile(1));
+# Test linenumber offset
+
+run_make_test(q!
+all: one two
+ $(warning in $@ line 3)
+ @true
+ $(warning in $@ line 5)
+
+one two:
+ $(warning in $@ line 8)
+ @true
+ $(warning in $@ line 10)
+!,
+ '', "#MAKEFILE#:8: in one line 8
+#MAKEFILE#:10: in one line 10
+#MAKEFILE#:8: in two line 8
+#MAKEFILE#:10: in two line 10
+#MAKEFILE#:3: in all line 3
+#MAKEFILE#:5: in all line 5\n");
+
# This tells the test driver that the perl test script executed properly.
1;
-
-
-
-
-
+### Local Variables:
+### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
+### End:
fputs (" private", stdout);
if (v->fileinfo.filenm)
printf (_(" (from '%s', line %lu)"),
- v->fileinfo.filenm, v->fileinfo.lineno);
+ v->fileinfo.filenm, v->fileinfo.lineno + v->fileinfo.offset);
putchar ('\n');
fputs (prefix, stdout);