Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the meaning of obj-m: in Linux device driver Makefile

I am very new to Linux device drivers.

In Makefile what is obj-m?

What is the difference between obj-m and obj-m+?

like image 512
Prashanth Avatar asked Sep 08 '19 07:09

Prashanth


People also ask

What does OBJ M mean?

From the Linux kernel documentation for obj-m: "$(obj-m) specifies object files that are built as kernel modules.". There isn't an obj-m+ . The + is part of the += operator to append to a variable. It can also be used to append subdirectories which will be entered recursively.

What is Obj Y in makefile?

These lines define the files to be built, any special compilation options, and any subdirectories to be entered recursively. The most simple kbuild makefile contains one line: Example: obj-y += foo.o. This tell kbuild that there is one object in that directory named foo.o. foo.o will be build from foo.

What is makefile in Linux kernel?

The top Makefile is responsible for building two major products: vmlinux (the resident kernel image) and modules (any module files). It builds these goals by recursively descending into the subdirectories of the kernel source tree. The list of subdirectories which are visited depends upon the kernel configuration.

What is makefile in kernel module?

A kernel module is not an independant executable, but an object file which will be linked into the kernel in runtime. As a result, they should be compiled with the -c flag. Also, all kernel modules have to be compiled with certain symbols defined.


1 Answers

"obj-m := .o"

The kbuild system in kernel will build mod_name.o from mod_name.c After linking these files will get kernel module mod_name.ko.

The above line can be put in either a "Kbuild" file or a "Makefile."

When the module is built from multiple sources, an additional line is needed listing the files:

<module_name>-y := <src1>.o <src2>.o ...

For detailed info about this you can refer here

like image 125
user12045319 Avatar answered Sep 21 '22 19:09

user12045319