问题描述
我搜索了这个问题的答案,但找不到任何好的答案.也许他们老了,有些东西变了,所以我再问一次.
I searched for the answer to this question but couldn't find any good. Maybe they're old and something has changed, so I ask again.
我的目录结构为:
my_project
src
bin
我想要这样,当我在根目录中进行 make 时,二进制文件会放在 ./bin 中,而不是杂乱无章的 ./src.但是如何?
I want that, when I do make in the root dir, the binaries are put in ./bin, instead of cluttering ./src. But how?
我正在使用 C++.我的 Makefile.am 没有什么特别之处.只是 bin_PROGRAM 和 _SOURCES 变量.
I am using C++. My Makefile.am has nothing special. Just the bin_PROGRAM and _SOURCES variables.
当我运行 make 时,生成的二进制文件被放入 ./src 中.我只是想让它们在 ./bin 中.
When I run make, the binaries generated are put into ./src. I simply want them in ./bin.
推荐答案
你的想法错了.
您的构建树位于您运行 configure
的任何地方.这就是 autoconf 的工作原理.您的包的用户(不想弄乱他们的源代码树)希望它以这种方式工作.
Your build tree is wherever you run configure
. That's how autoconf is designed to work. Users of your package (who do not want to clutter their source tree) will expect it to work this way.
这种方法是一种更通用的解决方案,比您想象的组织具有更大的灵活性.例如,想要在不同的文件系统上维护源代码和构建文件并不少见.
This approach is a more general solution with a lot more flexibility than the organization you're imagining. For instance, it's not terribly unusual to want to maintain sources and build files on separate filesystems.
这篇关于Automake 生成二进制文件到 bin/而不是在 src/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!