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.
my_driver-objs := a.o b.o c.o obj-m += my_driver.o
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
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.
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:
make nokia_2420_defconfig
make menuconfig HOST_LOADLIBES=-lncurses
cp mk-config-modules [kernel directory] cd [kernel directory] ./mk-config-modules
After the script finishes, you will get a file called config-modules. Now you must copy it into the debian/ directory of your package, and create a very simple rules file like this.
#!/usr/bin/make -f K_MODULES.<name> = drivers/somewhere/something.ko include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/rules/kernel-module.mkNow create an appropiate control file with a description for your <name> package (don't forget to make your package depend on module-init-tools-maemo), and a postinst file like this:
#! /bin/sh case "$1" in configure) depmod -a ;; esac #DEBHELPER#and a postrm file like this:
#! /bin/sh case "$1" in remove) depmod -a ;; esac #DEBHELPER#
Finally, you have to create a changelog file by using the dch command. I would suggest to use the same version number as the kernel, and use a revision number to differentiate between different builds (e.g. something like 2.6.21-1).
Now you may run dpkg-buildpackage and see if it works.