Kernel Module Building Environment
There really is not much to your own module. All you need is a
very simple Makefile (compared to 2.4, which was more of a
mess), plus your module code. In a short introduction, I will show the steps to
create the files that will get you started on kernel modules. This mini-HOWTO
is explicitly done for external modules, i.e. those outside of
the kernel tree.
In the Makefile, there must be a target which contains this one simple command:
make -C PATH_TO_KERNEL M=$$PWD;
Now in fact you only need to tell what the modules will be. Since we are outside of the main kernel tree and as such can not choose which modules -- should your packages consists of more -- we want to build. Let's just build them all. Use this line:
obj-m += keyboard.o mouse.o
First note that it still reads only dot-O, not dot-K-O as the extension! Also note that these designate two separate modules. If one module should be built out of multiple object files, use an additional line describing those files:
mouse-objs := driver.o sysctl.o serial.o psaux.o usb.o
An example of a very simplistic, but complete package with samples that you can use as you like, is contained within The Oops Module (see Files section below).