构建一个makefile依赖/继承树 [英] Build a makefile dependency / inheritance tree

查看:220
本文介绍了构建一个makefile依赖/继承树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抱歉,如果我解释这个严重或者是要求某些出血明显的事情,但我是新的Linux内核,并在深刻的一些...



我们有一个嵌入式linux系统,它带有一个包含数百个东西文件夹的(非常严格的文档)SDK,大多数文件夹包含rules.make,make,make.config或某些变体...而根文件夹包含一个主makefile& rules.make这意味着你可以从根文件夹中输入make sysall并构建整个包。



到目前为止这么好,但是试图调试这是一个问题,因为文档会说如下:



要使内核输出调试消息,只需定义#outputdebugmessagesplz



确定,但这些东西是在主制作/规则文件中定义的,其中一些在孩子make / rules / config文件中定义,有些在.h文件中...当然,这些东西从顶make.config开启/关闭是非常好的,而不是修改个人的.h文件,然后不得不记得再次关闭它们。 / p>

所以我认为递归构建一个树是一件有用的事情,从主make文件开始,按照它所做的一切,定义等等,但似乎没有一个简单的方法呢?



我假设我我在这里丢失了一个make选项,可以将这个信息输出,或者makefile / config的使用可以正常工作?

解决方案

你的情况并不罕见。在开发嵌入式系统时,您可能会遇到许多以特定方式解决问题的自定义系统。由于人们已经评论过您的问题,所以没有简单的方法为您的makefile结构/框架生成依赖图。但是您可以尝试一些事情,我将根据您的情况尝试提出建议。因为你说过:


新的Linux内核和深入的...



我们有一个嵌入式linux系统,它带有一个(非常糟糕的
文档)SDK,其中包含数百个文件夹


您可以尝试以下操作:




  • 如果您的SDK由第三方供应商提供,请尝试联系他们并获得一些支持。

  • SDK通常提供了一个抽象,可以与多个组件配合使用,而不需要深入了解每个组件的每个组件是如何实现的。尝试确定您的问题,就像您要仅定制内核配置,您可以在SDK上找到linux内核文件夹(假设您的SDK由一组文件夹组成,例如库,源代码的应用程序和东西,其中一个可能是内核),并运行 make menuconfig 。这将打开一个基于ncurses的配置GUI,您可以浏览和选择内核选项。

  • 正如人们已经指出的,您可以尝试运行 make -n 并检查输出。你也可以尝试运行 make -p |较少并检查输出,但是我不建议这样做,因为它只会打印从读取makefile中产生的数据库(规则和变量值)。你必须解析这个输出来找出你想要的内容。



基本上你应该尝试确定你想要的自定义并查看它与SDK的互动。如果是内核,那么只能使用它来为您提供一个起点。 linux内核有自己的makefile-build系统,命名为 kbuild 。您可以在内核的文档文件夹找到更多信息。



此外,尝试了解makefile如何工作将帮助您,如果您有一个复杂的makefile结构控制多个组件。以下是有关makefile的好资源:



GNU正式文档



O'Reilly的Open Book 使用GNU Make管理项目



此外,尝试构建自己的工具,您可以检查是否有一个开源项目可以执行所需的工作。谷歌的快速搜索给了我这个:





另外,检查这个问题这一个。您可能会找到与您一样的问题的人的有用信息。



希望它有帮助


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...

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.

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"

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.

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?

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?

解决方案

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. 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...

and

We have an embedded-linux system which arrives with a (very badly documented) SDK containing hundreds of folders of stuff

You could try the following things:

  • If your SDK is provided by a third-party vendor, try contacting them and get some support.
  • SDK's usually provide an abstraction to work with several components without a deep understanding of how each one of them really works. 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. This will open a ncurses-based configuration GUI that you can navigate and choose kernel options.
  • As people already pointed out, you can try to run make -n and check the output. You could also try to run 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. 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. 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. You can find more information about it at the kernel's Documentation folder.

Besides that, trying to understand how makefiles work will help you if you have a complex makefile structure controlling several components. The following are good resources to learn about makefiles:

GNU Make official documentation

O'Reilly's Open Book "Managing Projects with 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:

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!

这篇关于构建一个makefile依赖/继承树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆