English 中文(简体)
Fix source file search path when doing out-of-source autotools build within emacs
原标题:

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

最佳回答

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.

问题回答

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 !





相关问题
java in-memory on-the-fly class compilation (and loading)

I want to revisit an old question of mine about in-memory "compilation" of classes. Since about 1/2 a year have passed since I asked (and was somewhat answered), I d like to re-raise the issue and see ...

(c)make - resursive compile

Let s assume I have directories like: dir1 main.cpp dir2 abc.cpp dir3 def.cpp dir4 ghi.cpp jkl.cpp And let s assume that main.cpp ...

How to link to a static library in C?

I use code::blocks to compile my static library. The output result is a libstatic.a file. Now, how do I link to my library to use functions that were compiled? (I tried to use #include "libstatic.a"...

Statically linking Winsock?

I m using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I m looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I ...

热门标签