So far, we have dealt with very simple kernel modules that have had exactly one C source file. What about the (quite typical) real-world situation where there is more than one C source file for a single kernel module? All source files will have to be compiled and then linked together as a single .ko binary object.
For example, say we're building a kernel module project called projx. It consists of three C source files: prj1.c, prj2.c, and prj3.c. We want the final kernel module to be called projx.ko. The Makefile is where you specify these relationships, as shown:
obj-m := projx.o
projx-objs := prj1.o prj2.o prj3.o
In the preceding code, note how the projx label has been used after the obj-m directive and as the prefix for the
-objs directive on the next line. Of course, you can use any label. Our preceding example will have the kernel build system compile the three individual...