Building a single kernel module

J. K. Cliburn jcliburn at gmail.com
Tue Dec 20 17:57:56 UTC 2005


On 12/20/05, J. K. Cliburn <jcliburn at gmail.com> wrote:
> Instructions for (re)building a single kernel module in FC4 are simple
> and outlined in the Release Notes thusly.
>
> ********************************************
> 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)
>
> default:
>     $(MAKE) -C $(KDIR) M=$(PWD) modules
>
> Issue the make command to build the foo.ko module.
> ********************************************
>
> I've done this in the past, but for some reason, today it doesn't
> work.  I'm trying to rebuild the via-velocity kernel module.
>
> [root at osprey net]# uname -r
> 2.6.14-1.1653_FC4
> [root at osprey net]# pwd
> /usr/src/redhat/BUILD/kernel-2.6.14/linux-2.6.14/drivers/net
> [root at osprey net]# ls -l via-velocity.c
> -rw-r--r--  2 root root 88213 Dec 20 08:09 via-velocity.c
> [root at osprey net]# cat Makefile
> obj-m := via-velocity.o
>
> KDIR  := /lib/modules/$(shell uname -r)/build
> PWD   := $(shell pwd)
>
> default:
>     $(MAKE) -C $(KDIR) M=$(PWD) modules
> [root at osprey net]# make
> make: Nothing to be done for `default'.

Well, never mind.  I went to the $(KDIR) directory (above, as shown in
the Makefile) and got the module built.  (Still don't know why it
wouldn't work the other way.)

[root at osprey build]# cd /lib/modules/2.6.14-1.1653_FC4/build
[root at osprey build]# make
M=/usr/src/redhat/BUILD/kernel-2.6.14/linux-2.6.14/drivers/net modules
  CC [M]  /usr/src/redhat/BUILD/kernel-2.6.14/linux-2.6.14/drivers/net/via-velocity.o
  Building modules, stage 2.
  MODPOST
  CC      /usr/src/redhat/BUILD/kernel-2.6.14/linux-2.6.14/drivers/net/via-velocity.mod.o
  LD [M]  /usr/src/redhat/BUILD/kernel-2.6.14/linux-2.6.14/drivers/net/via-velocity.ko




More information about the fedora-list mailing list