#include<linux/init.h>
#include<linux/module.h>
static int __init hello_init(void)
{
printk(KERN_WARNING "hello world.\n");
return 0;
}
static void __exit hello_exit(void) //清除函数
{
printk(KERN_WARNING "goodbye cool world\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("luzheng");
Makefile
obj-m:=hello.o
KERNELDIR:=/lib/modules/3.13.6/build
PWD:=$(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
需要注意的是 $(MAKE)的前面是一个tab键