I am very new to Linux device drivers.
In Makefile what is obj-m
?
What is the difference between obj-m
and obj-m+
?
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.
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.
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.
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.
"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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With