Makefile 支持多种架构/配置
为 makefile 支持多种体系结构和配置的最简单方法是什么?例如,发布配置可能比调试配置使用更多的优化。是否应该将更改的选项定义为 makefile 中的变量,并依赖用户根据需要更新它们?
# Change to -O2 for release.
COMPILER_OPTIONS := -arch x86_64 -O0
或者这种事情应该在规则中处理吗?
*_Release.a:
# Recipe for building a release library, i.e., with optimization.
# Unsure how to integrate this with different architectures.
或者也许是两者的结合?
What's the easiest way to give a makefile support for multiple architectures and configurations? For example, a release configuration might use more optimization than a debug configuration. Should the changing options be defined as variables in the makefile, and users be relied on to update them as needed?
# Change to -O2 for release.
COMPILER_OPTIONS := -arch x86_64 -O0
Or should this sort of thing be handled in rules?
*_Release.a:
# Recipe for building a release library, i.e., with optimization.
# Unsure how to integrate this with different architectures.
Or perhaps a combination of the two?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
架构和配置是正交的;他们呼吁采取不同的方法。用户应该能够在构建时选择配置,最简洁的方法是使用不同的目标。但我认为尝试在一种架构上构建另一种架构是没有意义的,因此架构的选择应该自动处理。详细信息会根据您的需求而有所不同,但您的 makefile 最终可能看起来像这样:
Architectures and configurations are kind of orthogonal; they call for different approaches. The user should be able to choose the configuration at build time, and the cleanest way to do that is with different targets. But I see no sense in trying to build for one architecture on another, so the choice of architecture should be handled automatically. The details will vary with your needs, but your makefile might end up looking something like this:
最简单的方法是不同的目标。概述:
与不同的体系结构相同,尽管我自己不进行任何交叉编译。
Easiest way is different targets. In outline:
Same with different architectures, although I don't myself do any cross-compilation.