Automake 生成二进制文件到 bin/ 而不是 src/
我搜索了这个问题的答案,但找不到任何好的答案。也许他们老了,有些事情发生了变化,所以我再问一遍。
我的目录结构为:
my_project
src
bin
我希望,当我在根目录中 make 时,二进制文件放在 ./bin 中,而不是混乱./src.但如何呢?
编辑:我正在使用 C++。我的 Makefile.am 没有什么特别的。只是 bin_PROGRAM 和 _SOURCES 变量。
当我运行 make 时,生成的二进制文件被放入 ./src 中。我只想将它们放在 ./bin 中。
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.
I have a directory structure as:
my_project
src
bin
I want that, when I do make in the root dir, the binaries are put in ./bin, instead of cluttering ./src. But how?
EDIT: I am using C++. My Makefile.am has nothing special. Just the bin_PROGRAM and _SOURCES variables.
When I run make, the binaries generated are put into ./src. I simply want them in ./bin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你在这里有错误的想法。
您的构建树位于您运行
configure
的位置。这就是 autoconf 的工作原理。您的包的用户(不想弄乱他们的源代码树)将期望它以这种方式工作。这种方法是一种更通用的解决方案,比您想象的组织具有更大的灵活性。例如,想要在单独的文件系统上维护源代码和构建文件并不罕见。
You've got the wrong idea here.
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
,这是不必要的复杂。如果您不想弄乱源目录,请尝试以下操作:
这会将所有生成的文件(如 makefile、二进制文件、目标文件)放入
my_project/build
的子目录中。Automake doesn't cope very well if you try to set up your directories in a different way than it expects. What you want would involve writing extra rules to move the binaries to
../bin
after compiling them, which is needlessly complicated.If you don't want to clutter your source directory, try this:
That will put all the generated files (like makefiles, binaries, object files) in subdirectories of
my_project/build
.告诉 Automake 在某个目录中创建二进制文件的一种方法是将此目录添加到“bin_PROGRAMS”变量中的名称右侧。
考虑以下 src/Makefile.am:
它创建一个二进制“src/foo”,但您可以告诉 Automake 使用 src 中的源来创建一个二进制“bin/foo”:
我尝试使用一些包,甚至“make distcheck”吞掉了它。但不可能有那么大的黑客......
One way to tell Automake to create binaries in a certain directory is to add this directory right to the name in the "bin_PROGRAMS" variable.
Consider the following src/Makefile.am:
It creates a binary "src/foo", but you can tell Automake to use the sources in src to create a binary "bin/foo":
I tried it with some packages and even "make distcheck" swallows it. Can't be that much of a hack though...