如何从Makefile中读取文件?
我正在使用 GNU Make 构建一个多目录项目。 我的问题是如何使用单个 makefile 来构建多个设备? 例如,我的应用程序必须在各种 X、Y、Z 移动设备上运行,每个移动设备具有不同的属性,如屏幕尺寸、键盘类型、平台版本等。我必须传递 make -f
谁能建议如何做到这一点?如果能满足我的要求,更好的解决方案将不胜感激。
I am using GNU Make to build a multiple-directory project.
My question is how can I use single makefile to build multiple devices?
e.g. My application has to run on various X,Y,Z mobile devices each having different properties like screensize, keyboard type, platform version etc. I have to pass make -f <makefilename> <targetname>
. Here targetname can be device name and model like Samsung CorbyPlus, but my makefile has to go to particular dirname of samsung and open the .txt file or so where all above properties are defined. I have to read all of them during build time and access in my code through some macros/defines/flags.
Can anyone suggest how to do this? Even better solution for my requirement will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用配置 makefile。例如,假设您有多个设备及其配置:
config_device1.mk
config_device2.mk
然后您可以使用从命令行传递的特殊参数有条件地将它们包含到基本 makefile 中(< strong>make -f makefile DEVICE=dev_type1)并使用配置文件中的选项并处理它们:
makefile
顺便说一句,从长远来看(如果你现在没有时间限制)它是最好使用一些现有的构建系统,阅读其手册并坚持其方法。
I'd suggest using configuration makefiles. For example, suppose you have several device with its configurations:
config_device1.mk
config_device2.mk
Then you can conditionally include them into base makefile using special parameter passed from command line (make -f makefile DEVICE=dev_type1) and use options from configuration files and process them:
makefile
BTW, for a long perspective (if you don't have time constraints now) it's better to use some of existing build system, read its manual and stick to its methodology.