简体   繁体   English

建立一个makefile依赖项/继承树

[英]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: 您可以尝试以下操作:

  • If your SDK is provided by a third-party vendor, try contacting them and get some support. 如果您的SDK是由第三方供应商提供的,请尝试与他们联系并获得一些支持。
  • SDK's usually provide an abstraction to work with several components without a deep understanding of how each one of them really works. SDK通常会提供一种用于多个组件的抽象,而无需深入了解每个组件的实际工作原理。 Try to pinpoint your problem, like if you want to customize only the kernel configuration, you could find the linux kernel folder on your SDK (assuming your SDK is composed of a set of folders with things like libraries, source code of applications and stuff, one of them might be the kernel one) and run make menuconfig . 尝试找出你的问题,就像如果你想定制内核配置,你可以找到你的SDK的Linux内核文件夹中(假设你的SDK是由用的东西像图书馆一组文件夹中的应用程序和内容的源代码,其中之一可能是内核之一),然后运行make menuconfig This will open a ncurses-based configuration GUI that you can navigate and choose kernel options. 这将打开基于ncurses的配置GUI,您可以在其中导航并选择内核选项。
  • As people already pointed out, you can try to run make -n and check the output. 正如人们已经指出的那样,您可以尝试运行make -n并检查输出。 You could also try to run make -p | 您也可以尝试运行make -p | less and inspect the output, but I don't recommend this since it will only print the data base (rules and variable values) that results from reading the makefiles. 减少并检查输出,但是我不建议这样做,因为它只会打印由于读取makefile而产生的数据库(规则和变量值)。 You would have to parse this output to find out what you want in it. 您将必须解析此输出以找出所需的内容。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM