Reputation: 147
Just to expand with some examples, here is the problem: Given the following source:
/* hello.c */
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello world\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world\n");
}
/* end of hello.c */
and the following Makefile:
obj-m += hello.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 type make while in the same directory as the source and make files, I get the message: 'Nothing to be done for `all' The compilation seems to stop here and no object file is created.
Now just for testing, I tried a new simpler Makefile: TARGET := hello ${TARGET}.o: ${TARGET}.c
Running make gives me the new error:hello.c:1: fatal error: linux/module.h: No such file or directory.
however this file IS available in the folder:
/usr/src/linux-headers-2.6.35-22/include/linux
and also in
/usr/src/linux-headers-2.6.35-22-generic/include/linux
as is the kernel.h file
What am I missing, any ideas?
Thanks in advance
Upvotes: 1
Views: 7440
Reputation: 1119
Make sure the lines beginning with 'make' in your Makefile are indented by a tab character. That is the line below 'all:' and the line below 'clean:' should begin with a tab.
Upvotes: 1