为未设计为使用一个的 autotools 项目单独构建目录

Separate build directory for autotools projects not designed to use one

...抱歉,这必须是重复的,但我只是 运行 为那些正在制作自己的项目并可以更改构建系统设置的人提供答案。

我能否始终在单独的构建目录中编译程序,还是必须由程序的构建系统支持?

对于 vim,您可以使用:“./configure && make && sudo make install”进行编译。如果我在 vim.hg.build 和 运行 "../vim.hg/configure .....",我得到:

../vim.hg/configure: line 6: cd: src: No such file or directory

对于 git,您可以使用:"make configure && ./configure && make && sudo make install" 进行编译。我希望在 git.git.build 和 运行ning "make --directory=../git.git configure" 中可以工作,但是配置文件留在 ../git.git 中。好吧,也许留下的配置还不错,所以我尝试了“../git.git/configure”,成功创建了 config.status、config.log 和 config.mak.autogen 在构建目录中。但是 运行ning make 给出:

make: *** No targets specified and no makefile found.  Stop.

... 是的,唯一的 Makefile 在 git.git 本身。

我什至尝试通过 运行ning 对整个目录进行符号链接:

for fl in `ls -a ../vim.hg`; do
    echo "$fl"
    ln -s ../vim.hg/$fl $fl
done

... 但是,vim 的 configure 和 make 只修改现有的文件和子目录,所以即使我可以这样构建,构建目录只剩下符号链接——没有实际的分离。

开始制作吧!

树外构建是 Autotools 的一项功能,需要 Autoconf 和 A​​utomake。

Vim 和 Git 都只使用 Autoconf 而不是 Automake,因此他们无法利用该功能。

作为对您问题的更笼统的回答:简单的 Autotools 项目应该自动使用树外构建。在使用某些高级功能时,必须小心以确保树外构建继续工作。有时项目不会这样做。

(运行 make distcheck 将测试树外构建,因此最好在发布前至少 运行 一次。)