world leader in high performance signal processing
Trace: » building

Building 2.6 Kernel Modules

A new method is used to trigger the kernel to build a module outside the kernel tree. The device drivers section will show you how to simply add module building instructions to a normal kernel makefile

Here is an example of a 2.6 module makefile ( out of tree )

                                                             
                                                              
ifneq ($(KERNELRELEASE),)                                     
##################################################            
# PASS 2 do this when called by the kernel make process              
##################################################            
# produce a module from a single C file
obj-$(CONFIG_MYMOD) += mymod.o

# or  produce a module from multiple C files                    
                                                              
#   obj-$(CONFIG_MYMOD) += mymod.o                            
#  mymod-objs := mymod_main.o mymod_lib.o mymod_io.o          
                                                              
                                                              
else 
                                                         
##################################################            
# PASS 1 do this when called from the user make                      
##################################################            
    KDIR        := /home/student/work/uClinux-dist/linux-2.6.x
    PWD         := $(shell pwd)                               
                                                              
default:                                                      
<TAB>$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules                
                                                              
install:                                                      
<TAB>$(MAKE) -C $(KDIR) INSTALL_MOD_PATH=$(IDIR) \            
                    SUBDIRS=$(PWD) modules_install            
endif                                                         
                                                              
Kernel Module out of tree build

The module build process can be instructed to place the modules in a different target directory and use source directories outside the kernel source tree.

When the modules needs to be installed under another directory the INSTALL_MOD_PATH directive can be used to prefix ”/lib/modules” as seen in the following example:

                                                                      
make INSTALL_MOD_PATH=/home/student/work/build/image modules_install  
                                                                      

This will install the modules in the directory

    /home/student/work/build/image/lib/modules.                       
                                                                      

This directory can be a NFS mounted filesystem on another machine, allowing out-of-the-tree support for installation on remote machines.