views:

163

answers:

2

Hi

I have a project that uses autotools. A nice feature of autotools is 'out-of-source' builds, wheras instead of doing :

cd foobar
./configure
make

I actually create a folder for builds, in which I do the configuration :

cd foobar/builds/linux
../../configure
make

(The nicety is that my source folder is not crippled with the generated Makefiles, and it helps when cross-compiling).

So when I am working on my code in emacs, to run the compilation I'll do M-x compile specifying the compile command as cd ~/foobar/builds/linux ; make .

This works fine until a compilation error occurs. The compilation buffer will list the files with ugly path (like ../../../../src...), which points to a source file, relative to the build folder.However, it seems like emacs does not stay in the build folder at the end of the compile, so the link does not point to anything. Hence, I cannot easily browse back to the error.

I tried playing with compilation-search-path, whithout luck.

Is there a way to force emacs to 'stay' in the compilation folder (so that the paths in the compilation buffer reference existing files ?)

Thanks

PH

+4  A: 

If you instead use make -C ~/foobar/builds/linux, emacs should be able to track the Entering directory ..., Leaving directory ... messages that make emits and use this to keep proper references to the files.

jamessan
Thanks, but it does not seem to help .. I should probably add that I have several source folders, and that I run make at the top-level. For example : * I build in /home/phtrivier/prj/foobar/builds/linux/current* I have an error in a file from /home/phtrivier/prj/foobar/src/clientIn the compile buffer, with 'make -C ~/foobar/builds/linux/current check' I get the error : make[2]: entrant dans le répertoire « /home/phtrivier/prj/foobar/builds/linux/current/src/client...(compilation line skipped)../../../../../src/client/whatever.cppBut when clicking on the line, it is not found :(
phtrivier
A: 

Using jamessan advice, I could partially fix the issue by :

  • setting 'compilation-directory to be one of the 'source' folders (builds/linux/current/src/client)
  • settting 'compilation-command to change to one of those source folders using -C

Not so sure if both are needed or if it is the best way to do things ...

Thanks anyway !

phtrivier