Cannot compile kernel modules

Submitted by shady_Dev
on January 4, 2009 - 3:50am

Hi,
I m trying to compile some simple kernel module hello-1.c but i m getting the following error.I m using Fedora 8 ,my kernel version is 2.6.23.1.

make: Nothing to be done for `default'.

Plz help me..

Here is my make file

ifneq ($(KERNELRELEASE),)
obj-m := hello-1.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif

I've tried simple make file by omitting the other lines as follows:

obj-m := hello-1.o
default:
make -C /lib/modules/$(shell uname -r)/build $(shell pwd) modules

But this too is not working.Does this problem have something to do with HOSTCC/scripts?? plz tell me the solution.

Thanks in advance!!

Makefile

beparas
on
January 4, 2009 - 9:20pm

In Makefile the command part always start with the TAB character.
so start the "make -C /lib/modules/$(shell uname -r)/build $(shell pwd) modules" command with TAB character.

Everything ok with the make file, still not compiling

shady_Dev
on
January 5, 2009 - 3:50am

I have taken care of the tabs but its not still compiling.BTW if there would have been a tab problem then the make utility would have reported such an error. viz.Make: Must be a separator on rules line n. Stop

My kernel module i.e. hello-1.c remains uncompiled.Following is the output i m getting now.

[root@localhost syspro]# make -C /lib/modules/2.6.23.1-42.fc8/build/ SUBDIRS=$PWD modules
make: Entering directory `/usr/src/kernels/2.6.23.1-42.fc8-i686'
Building modules, stage 2.
MODPOST 0 modules
make: Leaving directory `/usr/src/kernels/2.6.23.1-42.fc8-i686'

Here is my make file:
obj-m+= hello-1.o

Plz help me..
Thanks in advance!!

Need to mention the M= option

Anonymous (not verified)
on
January 6, 2009 - 5:19pm

The command “make –C $(KDIR) M=$(PWD) modules “ , changing its directory to the one provided with the –C option i.e., the kernel source directory. There it finds the kernel’s top-level makefile.

The M= option causes that makefile to move back into your module source directory before trying to build the modules target. If you have not specified M= the kernel will not change the directory.

In your makefile M= option is missing, you just need to mention that in make command as given below:

M=$(shell pwd) or M=$(PWD)

or

try with the following code:

Obj-m += hello-1.c
KDIR := /lib/module/$(shell pwd)/build
PWD := $(shell pwd)
all:
make –C $(KDIR) M=$(PWD) modules
clean:
rm -f *.mod.c *.ko *.o

I hope the above code should solve your problem.

-raosg

@above

sunr2007
on
January 28, 2009 - 12:01pm

Hi,
I think in your make file the path of your kernel source should be in place of the below line
KERNELDIR ?= /lib/modules/$(shell uname -r)/build

KERNELDIR?=/
for example if you have kernel source directory something like this /home/usr/ then this should be included in your KERNELDIR
.
warm regards,
Ravi Kulkarni

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.