Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux kernel module compiling

I try to compile simple linux kernel module:

#include <linux/module.h>    
#include <linux/kernel.h>       

int init_module(void)
{
        printk("Hello world 1.\n");
        return 0;
}

void cleanup_module(void)
{
        printk(KERN_ALERT "Goodbye world 1.\n");
}

My makefile:

obj-m = testmodule.o
KVERSION = $(shell uname -r)
all:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean

Now i haven't errors in my .c file.

But when i try make in terminal: make: Nothing to be done for `all'.

What's wrong?

Thank you.

like image 957
0xAX Avatar asked Oct 31 '10 15:10

0xAX


1 Answers

The default command in your makefile is

make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules

That instructs make to cd to /lib/modules/$(KVERSION)/build and run

make module m=YOUR_CURRENT_DIR

In turn, that makefile is not finding anything to do. Presumably, that makefile expects to find some particular structure in your current directory.

You need to more carefully read whatever instructions led you to set up this makefile.

like image 76
bmargulies Avatar answered Sep 21 '22 02:09

bmargulies