[英]Build a makefile dependency / inheritance tree
Apologies if I explain this badly or am asking something bleeding obvious but I'm new to the Linux kernel and kinda in at the deep end... 抱歉,如果我不好解释这一点,或者正在问一些明显的问题,但是我是Linux内核的新手,并且在很深的地方有点...
We have an embedded-linux system which arrives with a (very badly documented) SDK containing hundreds of folders of stuff , most folders containing a rules.make, make, make.config or some variation of... and the root folder containing a "master" makefile & rules.make which mean that you can, from the root folder, type "make sysall" and it builds the entire package. 我们有一个嵌入式Linux系统与包含数百个东西文件夹的(非常糟糕记录)SDK到达,包含编译规则,化妆,make.config或一些变化......而根文件夹包含一个文件夹最多“ master” makefile&rules.make意味着您可以从根文件夹中键入“ make sysall”,它会构建整个软件包。
So far so good, but trying to debug it is a bit of an issue as the documentation will say something like: 到目前为止,还不错,但是尝试调试它是一个问题,因为文档将显示类似以下内容:
" To get the kernel to output debug messages, just define #outputdebugmessagesplz " “ 要使内核输出调试消息,只需定义#outputdebugmessagesplz ”
OK, but some of these things are defined in the "master" make/rules file, some of these are defined in the child make/rules/config files, some are in .h files... and of course it's far nicer to turn these things on/off from the "top" make.config rather than modifying individual .h files and then having to remember to turn them off again. 好的,但是其中一些是在“主” make / rules文件中定义的,其中一些是在子make / rules / config文件中定义的,其中一些是在.h文件中的……当然,这要好得多从“顶部” make.config启用/禁用这些功能,而不是修改单个.h文件,然后必须记住再次将其关闭。
So I thought it would be a useful thing to recursively build a tree, starting from the master "make" file and following everything it does, everything that gets defined or re-defined, etc... but there doesn't seem to be a simple way of doing that? 因此,我认为从主“ make”文件开始并按照其所做的所有操作,定义或重新定义的所有内容进行递归构建树是很有用的,但是似乎并没有一个简单的方法吗?
I assume I am missing a "make" option here that spits this info out, or a usage of the makefile/config that will just work? 我假设我在这里错过了一个“ make”选项,该选项会吐出此信息,或者使用将正常工作的makefile / config?
Your situation is not uncommon. 您的情况并不罕见。 When developing for embedded systems, you might encounter many custom systems that solve a problem in a specific way. 在为嵌入式系统开发时,您可能会遇到许多以特定方式解决问题的自定义系统。 As people already commented on your question, there's no easy way to generate a dependency graph for your makefile structure/framework. 正如人们已经对您的问题发表评论一样,没有一种简单的方法可以为您的makefile结构/框架生成依赖关系图。 But there are some things you can try, and I'll try to base my suggestions based on your situation. 但是您可以尝试一些方法,我将根据您的情况尝试提出建议。 Since you've said: 既然您说过:
Im new to the Linux kernel and kinda in at the deep end... 我是Linux内核的新手,有点深入...
and 和
We have an embedded-linux system which arrives with a (very badly documented) SDK containing hundreds of folders of stuff 我们有一个嵌入式Linux系统,该系统附带一个(包含大量文献)的SDK,其中包含数百个文件夹
You could try the following things: 您可以尝试以下操作:
Basically, you should try to pinpoint what you want to customize and see how this interacts with your SDK. 基本上,您应该尝试确定要自定义的内容,并了解它如何与SDK交互。 If it's the kernel, then working only with it will give you a starting point. 如果是内核,那么仅使用它会为您提供一个起点。 The linux kernel has its own makefile-build system, named kbuild . linux内核有自己的makefile-build系统,名为kbuild 。 You can find more information about it at the kernel's Documentation folder . 您可以在内核的Documentation文件夹中找到有关它的更多信息。
Besides that, trying to understand how makefiles work will help you if you have a complex makefile structure controlling several components. 除此之外,如果您拥有控制多个组件的复杂makefile结构,那么尝试了解makefile的工作原理将对您有所帮助。 The following are good resources to learn about makefiles: 以下是学习makefile的好资源:
GNU Make official documentation GNU Make官方文档
O'Reilly's Open Book "Managing Projects with GNU Make" O'Reilly的公开书“使用GNU Make管理项目”
Also, before trying to build your own tool, you can check if there's an open source project that does what you want. 另外,在尝试构建自己的工具之前,您可以检查是否有一个开源项目可以满足您的需求。 A quick search on google gave me this: 在Google上进行的快速搜索为我提供了这一点:
Also, check this question and this one . 另外,请检查此问题和该 问题 。 You might find useful information from people that had the same problems as you did. 您可能会从遇到同样问题的人那里找到有用的信息。
Hope it helps! 希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.