Makefile:
PWD = $(shell pwd)
KERNEL_SRC = /usr/src/linux-headers-2.6.32-28-generic/
obj-m := test.o
module-objs := test.o
all:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
clean:
rm *.ko rm *.o
test.c:
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
//#include <stdio.h>
static int __init test_init(void)
{
printk("init modulen");
return 0;
}
static void __exit test_exit(void)
{
printk("exit modulesn");
}
module_init(test_init);
module_exit(test_exit);