将 GNU make 生成的文件存储在其他地方
我如何存储 GNU make &在其他地方配置文件?我正在开发一个项目,我使用以下方法进行编译:
./configure --prefix=/usr && make && su -c 'make install'
问题是我不想污染当前文件夹,该文件夹是一个 svn/git/hg/whatever 沙箱,其中包含该命令生成的文件。我想将这些文件放在单独的位置。我不知道它是否相似,但是当我从源代码编译 Linux 内核时,我可以通过将 'O' 选项传递给 'make' 来指定将输出放在哪里,如下所示:
make O=/home/user/linux-output
How can I store GNU make & configure files elsewhere? I have a project I am working on that I get compiled using:
./configure --prefix=/usr && make && su -c 'make install'
The thing is I don't want to pollute the current folder, which is a svn/git/hg/whatever sandbox with files generated by that command. I want to put those files in a separate location. I don't know if it's similar, but when I compile the linux kernel from source, I can specify where to put the ouput by passing the 'O' option to 'make', something like this:
make O=/home/user/linux-output
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Makefile 必须支持此功能。
我认为 autoconf 生成的 makefile 都支持以下用途:(
当然推荐用于 gcc 构建)。
The Makefile must support this feature.
I think the autoconf generated makefiles all support the following use:
(It's certainly recommended for gcc builds).
正如 Kristof 已经指出的那样,GNU 自动工具本质上支持配置级别的树外构建。
因此,您可以轻松地从源代码树中获取 Makefile 和构建的二进制文件。
然而,要从源代码树中获取所有自动生成的工件,需要做更多的工作。
我们有一个脚本,可以将源树中的更改复制到工作副本中,并在工作副本中仔细保留配置脚本等,从而使原始源树保持原始状态。但它的效率非常低,所以我不推荐它。
我建议使用正常的树外构建,然后明确排除源树中剩余的自动生成的文件。
As Kristof already pointed out, GNU autotools inherently support out out-of-tree builds at the
configure
level.So you can have the Makefile and built binaries out of the source tree trivially.
To get all the auto-generated artefacts out of the source tree requires much more work however.
We have a script that copies changes from a source tree into a working_copy, carefully preserving the configure script etc in the working_copy, which allows the original source tree to be pristine. However it's very inefficient, so I wouldn't recommend it.
I would recommend a normal out-of-tree build, and then explicitly excluding the remaining auto-generated files in the source tree.