Kconfig and makefile of Linux drivers

Source: Internet
Author: User

In the Linux authoring process, there are two files that we must understand and know. One of these is the Kconfig file, and the other is the makefile file. If you are familiar with it, then it is certainly necessary for the kernel to compile the. config file, in the. config file, we found that some modules were compiled into the kernel, and some just generated a module. In the middle, how do we let the kernel discover the modules we write, which we need to explain in kconfig. As for how to generate the module, you need to use Makefile to tell the compiler how to build the module. Imitation is actually the best teacher, we can use the Kernel network card e1000 module as an example, explain how the kernel is set up and compiled.

First, we can take a look at how e1000 is described in Kconfig in,

The above content is extracted from the drivers/net/kconfig. Content does not look complicated, the most important thing is to explain the module name, purpose, dependent module name, description and so on. As long as we have this note, we can see the e1000 option when we enter make menuconfig under the shell, enter Y to compile the kernel, enter N to not compile, and enter M to write the module, which is known to all.

So, with this module, which files need to be compiled, we see this content in Drivers/net/makefile,

Obviously, this code just tell us, want to compile e1000, must contain e1000 this directory, so e1000 directory there is bound to have a makefile, sure enough, we found this e1000 in the makefile directory, the content is as follows,

Read this document, in fact, we should have the bottom of psychology. Originally this e1000 module final generated file is E1000.ko, dependent on the file is E1000_main.c, e1000_hw.c, E1000_ETHTOOL.C, e1000_param.c these four files. As long as the config_e1000 is set, the module will be compiled normally. All we have to do is turn on the switch and the rest of the kernel will help us get everything done. Of course, if you want to get this module out, it is possible to compile it yourself with a separate module.

The compilation of Linux drivers is actually more important than the two configuration files.

Kconfig and makefile of Linux drivers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.