Create a makefile dependency / inheritance tree.

I apologize if I explain it badly or I ask you to bleed something obvious, but I'm new to the Linux kernel and curious in depth ...

We have an embedded linux system that comes with a (very poorly documented) SDK containing hundreds of file folders, most folders containing rules.make, make, make.config or some changes ... and the root containing the "master" makefile and rules.make, which means that you can type β€œmake sysall” in the root folder and build the whole package.

So far, so good, but trying to debug is a bit of a problem, as the documentation will say something like:

"To force the kernel to output debugging messages, simply define #outputdebugmessagesplz"

OK, but some of these things are defined in the make / rules "master" file, some of them are defined in the make / rules / config files for children, some of them are in the .h files ... and, of course, it's much better enable or disable these things from the "top" make.config, rather than changing individual .h files, and then forget to turn them off again.

So I thought it would be useful to build a tree recursively, starting with the main make file and follow everything that it does, everything that is defined or redefined, etc., but there doesn't seem to be an easy way to do this?

I assume that I do not have the "make" option that spits out this information or uses the makefile / config file that will work?

+6
source share
1 answer

Your situation is not uncommon. When developing embedded systems, you may encounter many customizable systems that will solve the problem in a specific way. Since people have already commented on your question, there is no easy way to generate a dependency graph for your structure / makefile structure. But there are some things you can try, and I will try to base my suggestions based on your situation. Since you said:

Im new to the Linux kernel and kinda in the deep end ...

and

We have an embedded linux system that comes with a (very poorly documented) SDK containing hundreds of folders of things

You can try the following things:

  • If your SDK is provided by a third-party vendor, try contacting it and get some support.
  • The SDK typically provides an abstraction for working with multiple components without a deep understanding of how each one really works. Try to identify your problem, for example, if you want to configure only the kernel configuration, you can find the Linux kernel folder on the SDK (if your SDK consists of a set of folders with things like libraries, application source code, etc., one of them may be the kernel ) and run make menuconfig . This will open the ncurses-based graphical configuration interface, which you can move and select kernel options.
  • As people have already pointed out, you can try running make -n and check the output. You can also try running make -p | less and check the output, but I do not recommend it, since it will only print the database (rules and values ​​of variables) that occurs when reading make files. You will need to parse this conclusion to find out what you want in it.

Basically, you should try to determine what you want to configure, and see how this interacts with your SDK. If this is the core, then working with it will give you a starting point. The Linux kernel has its own makefile-build system called kbuild . Further information on this can be found in the kernel documentation folder .

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

GNU Make White Papers

O'Reilly Open Book "Project Management with GNU Make

In addition, before trying to create your own tool, you can check if there is an open source project that does what you want. A quick google search gave me the following:

Also, mark this question and this . You could find useful information from people who had the same problems as you.

Hope this helps!

+2
source

All Articles