PDA

View Full Version : Not able to build the kernel module using make



akshata
September 14th, 2008, 09:44 PM
Hi,
I have witten the following C program test.c for kernel 2.6

#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}


and the coressponding Makefile as

obj−m += hello−1.o
all:
make −C /lib/modules/$(shell uname −r)/build M=$(PWD) modules
clean:
make −C /lib/modules/$(shell uname −r)/build M=$(PWD) clean


When i run a make command in the same directory i get the following output
make: Nothing to be done for 'all'


The test.ko file is not getting created. Please can anyone tell me what the problem is and how to rectify it?

Thanks,
Akshata

dwhitney67
September 15th, 2008, 03:35 AM
Your Makefile looks like the suspect here.

Statements that are associated with a Makefile entry point (e.g. 'all' and 'clean') need to be indented with a tab-space. For instance:

obj-m += test.o

all:
<tab>make −C /lib/modules/$(shell uname −r)/build M=$(PWD) modules

clean:
<tab>make −C /lib/modules/$(shell uname −r)/build M=$(PWD) clean
Btw, is your C source-file named "test.c" or "hello-1.c"?? Please update the obj-m section of the Makefile accordingly.

akshata
September 15th, 2008, 05:48 AM
Thanks a lot!! The <tab> did turn out to be the culprit!!

Thanks again..