设备驱动之一 - 多源文件驱动模块的Makefile写法

       对于含有多个源文件的驱动模块,其Makefile如何写哪,在网上搜索了很多,但是很少有成功的。通过不懈的搜索和“篡改”,先将争取的模版发布出来

       当前目录./的文件如下:

       ./-----

          |-----scull.h

          |-----scullmod.c

          |-----file.h

          |-----file.c

       现在要编译出一个模块scull.ko,其Makefile如下:

obj-m += scull.o 
scull-objs := scullmod.o file.o 
KERNELBUILD := /lib/modules/$(shell uname -r)/build
default:
	$(MAKE) -C $(KERNELBUILD) M=$(shell pwd) modules
clean:
	-rm -rf *.o .*.cmd *.ko* *.mod.c .tmp_versions
	-rm -rf  modules.order Module.symvers

注意:

      1. 模块文件scull.o不能与其依赖的.o文件重名

 

参考资料:

     http://www.2898.com/1919796.html

 

     

posted on 2012-07-10 21:24  YoungerChina  阅读(443)  评论(0编辑  收藏  举报

导航