原创 嵌入式linux驱动编译

2010-5-11 22:03 3838 3 3 分类: MCU/ 嵌入式

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的内核路径、编译语句,都没写出来。

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
我要评论
0
3
关闭 站长推荐上一条 /1 下一条