2015-12-10 09:31:01
来 源
中存储网
Ubuntu
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/ker

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);

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。