Using the linux-headers package

There are two separate cases which have to be handled in different ways. The first case is for building out-of-kernel-tree modules (not included in standard Diablo kernel source tree), and the second case is for building in-kernel-tree modules.

Out-of-tree modules

  1. Create a separate directory for your driver (./my_driver/ in the example below).
  2. Create a standard kernel Makefile for your driver (./my_driver/Makefile), something like this:
    my_driver-objs := a.o b.o c.o
    obj-m += my_driver.o
    
  3. Run kernel build system like this (./Makefile):
    include /usr/share/cdbs/1/rules/kernel-module-oot.mk
    
    DRVDIR = $(shell pwd)/my_driver
    
    all:
    	make -C $(K_BUILD) M=$(DRVDIR)/ modules
    
    clean:
    	make -C $(K_BUILD) M=$(DRVDIR)/ clean
    
  4. Now you can invoke "make" to build the driver and "make clean" will clean the build directory.

If you want to create a Debian package for your out-of-tree modules, you can look at one of the module packages from our SVN:

svn checkout https://garage.maemo.org/svn/kmod

and model yours using one of existing packages as a template.

In-tree modules

Building in-tree modules is, on one hand, simpler but on other hand more complex :-)

First of all, you must prepare a special file called config-modules, which will contain the kernel config for the drivers you selected to build. The easiest way to build a config-modules file is the following: