There's no fundamental difference between Android and other Linux platforms. To build a module, you need kernel headers and a few files that are generated during the kernel compilation. These files depend on the kernel configuration. Typical Linux distributions ship with a package containing these kernel headers and other files, to make it easier to build custom modules. I don't think the Android NDK comes with kernel headers (compared with the number of people who write native applications, very few people build kernel modules, and many are hardware manufacturers who are building their own system image anyway).
So get the Android source, specifically the kernel tree (
kernel/common). Get the kernel configuration for the device you're targetting; the default image provides its configuration in
/proc/config.gz, you can get it with
adb shell 'gzip -d </proc/config.gz'.
Once you have the source tree and the configuration file, follow the usual drill: copy your configuration file to
.config in the kernel tree, run
make oldconfig and
make modules_prepare, then
make M=/path/to/your/module/tree to build your module. The Linux Kernel Module Programming Guide and Linux Device Drivers are good references; the kernel build system is documented in
If the device you're targetting doesn't have modules enabled (
CONFIG_MODULES in the configuration file), you'll need to rebuild a kernel with modules and copy it into your system image.
The Android image in the emulator comes with very basic module utilities:
rmmod are present, but
insmod isn't capable of specifying arguments. If that's a problem, get Busybox (it's useful for other things as well). You can get it from the Market or compile it from source.
There are many tutorials on kernel and module compilation for Android. Here are a few; I've only skimmed them so I don't guarantee quality.