Automake 变量来整理 Makefile.am
我有一个目录 /src 包含所有源文件, /bin 用来在运行 make 命令后存储所有二进制文件。该目录如下所示:
/BuildDirectory
- - /src
- - /bin
- - configure
- - Makefile.am
- - configure.ac
- - ...
现在在 Makefile.am 中,我必须指定:
bin_PROGRAMS = bin/x bin/y bin/z bin/k ...
bin_x_SOURCES = src/x.cpp
bin_y_SOURCES = src/y.cpp
bin_z_SOURCES = src/z.cpp
是否有任何变量可以帮助摆脱所有“bin/”和“src/”? 例如,我只是指定:
$BIN = bin
$SRC = src
他们将在正确的文件夹中查找正确的文件并将其编译到正确的位置。
谢谢
I have a directory /src containing all of my source files, and /bin to store all binary after running make command. The directory is something like below:
/BuildDirectory
- - /src
- - /bin
- - configure
- - Makefile.am
- - configure.ac
- - ...
Now in Makefile.am, I have to specified:
bin_PROGRAMS = bin/x bin/y bin/z bin/k ...
bin_x_SOURCES = src/x.cpp
bin_y_SOURCES = src/y.cpp
bin_z_SOURCES = src/z.cpp
Is there any variable that can help to get rid of all "bin/" and "src/" ?
For example I just specify:
$BIN = bin
$SRC = src
And they will look for the correct files in correct folders and compile it to the correct places.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以利用远程构建。将此 makefile 放入 bin 目录中:
现在用此替换当前的 Makefile.am:
现在调整您的configure.ac 以也生成 bin/Makefile,
并且您应该终身设置。
You could take advantage of remote building. Place this makefile in the bin dir:
Now replace the current Makefile.am with this one:
Now tweak your configure.ac to also generate bin/Makefile
and you should be set for life.
据我所知。如果您希望将编译后的文件与源文件分开,请记住您可以在树之外构建:
如果这是您想要做的,您可以创建
Makefile.am
通过创建没有目录前缀的二进制文件(并且仍然手动引用 src/ 中的内容)来更简单。Not to my knowledge. If you're looking to separate your compiled files from your source files, remember that you can build outside of the tree:
If this is what you're looking to do, you can make the
Makefile.am
simpler by creating binaries without a directory prefix (and still referencing things insrc/
by hand).如果你想做的就是我认为你想做的,那么你正在尝试实现类似的目标:
我已经以各种形式测试了几次,并且它不会编译代码以你为例;我以某种方式确信它在某个阶段编译了 C:
因此我相当确定这是不可能的。对不起。
If what you're trying to do is what I think you're trying to do, you're trying to achieve something like:
I've tested this a few times in various forms, and it won't compile the code as it would with your example; I somehow convinced it that it was compiling C at one stage:
I'm thus fairly certain that it's not possible. Sorry.