Linux驱动编译makefile写法:
一、一个驱动文件由多个原文件组成:
1、hello.c:
int hello_init(void){printk("Cinc test: hello! ");return 0;}
module_init(hello_init);
2、hello2.c:
void hello_exit(void){printk("Cinc test: goodbye!");}
module_exit(hello_exit);
1、makefile:
obj-m := hell.o
hell-y += hello.o hello2.o
二、多个原文件同时生成多个驱动文件
1、hello.c:
int hello_init(void){printk("Cinc test: hello! ");return 0;}
void hello_exit(void){printk("Cinc test: goodbye!");}
module_init(hello_init);
module_exit(hello_exit);
2、hello2.c:
int hello_init(void){printk("Cinc test2: hello! ");return 0;}
void hello_exit(void){printk("Cinc test2: goodbye!");}
module_init(hello_init);
module_exit(hello_exit);
3、Makefile:
obj-m += hello.o hello2.o
注:此笔记只是简单记录重要部分,其中C文件的包含头文件代码和Makefile的内核路径、编译语句,都没写出来。
文章评论(0条评论)
登录后参与讨论