Product SiteDocumentation Site

7.7. Building Only Kernel Modules

An exploded source tree is not required to build a kernel module, such as your own device driver, against the currently in-use kernel. Only the kernel-devel package is required to build external modules. If you did not select it during installation, use Pirut to install it, going to ApplicationsAdd/Remove Software or use yum to install it. Run the following command to install the kernel-devel package using yum.
su -c 'yum install kernel-devel'

For example, to build the foo.ko module, create the following Makefile in the directory containing the foo.c file:
obj-m := foo.o 

KDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)

    $(MAKE) -C $(KDIR) M=$(PWD) modules

Issue the make command to build the foo.ko module.