Question

I'm compiling an autotools C based project and I'm getting some warnings and errors. They are displayed like this:

foo.c:123: warning: some message

I would like them to be displayed like this:

/full/path/to/foo.c:123: warning: some message

I know this is not configurable through gcc except by passing to it the full file path itself, so I guess that this must be configurable through autoconf/automake.

Is this possible? If so, how?

Was it helpful?

Solution

I don't know how to do that and suspect that it cannot be done. BUT if your higher goal is to find the files referenced by the warnings it may be enough to use Emacs:

Open a file in the top source directory, like C-x C-f configure.ac RET, run the compilation: M-x compile RET (possibly edit the make command) RET. When you see a warning in the compilation buffer, use C-x backtick (C-x `) to display the source location.

Emacs manages this by parsing the "Entering directory /foo" and "Leaving directory /foo" messages from make so you may want to emulate that.

OTHER TIPS

Here is a trick that may work for you.

One can add the following line in Makefile.am

VPATH = $(abs_srcdir)

This will generate Makefile that will search source directory by referring the directory via absolute path. In turn, gcc will receive absolute paths for the source files.

I am NOT sure this trick will work for all vesions of make. In some versions of make the value of variable VPATH is read as flat text and make does not substitute the value of abs_srcdir.

I think you might be able to do this, but it might cause problems with other autotools make targets (e.g. make dist), so I'd advise against it. There are absolute analogs to the top_srcdir, top_builddir, srcdir and builddir variables prefixed with abs_ (e.g. abs_top_srcdir). So you might try prefixing your source files with these before compiling them with gcc.

I'm not sure why you think that autotools should do this. How warnings/errors are printed out is a feature of the C compiler (gcc), not of autotools.

For out of tree builds, there is a difference in the file names used to refer to source files between

mkdir _build
cd _build
../source-tree/configure --prefix=...

and

mkdir _build
cd _build
$PWD/../source-tree/configure --prefix=...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top