简单的驱动makefile详解
一个工程中的源文件不计数,其按类型、功能、模块分别放在若干个目录中,makefile定义了一系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译,甚至于进行更复杂的功能操作,因为 makefile就像一个Shell脚本一样,其中也可以执行操作系统的命令。
Linux 2.6 (PC)简单驱动Makefile详解
ifneq ($(KERNELRELEASE),)
module-objs := book.o
obj-m := book.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~nd.* * * versions
KERNELRELEASE 内核顶层目录Makefile的`一个变量。
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
内核源码树目录。
该Makefile 共读取两次,在输入Makefile时,$(KERNELDIR) 第一次读取KERNELRELEASE并没有被定义,然后就开始读取内核源码的目录,开始定义KERNELRELEASE,然后到当前模块的目录里面,M=$(PWD) 进入该Makefile时KERNELRELEAS已经被定义了,读取要编译的模块,然后再返回到modules
编译完成,产生文件
Linux 2.6 (ARM)简单驱动Makefile详解
ifneq ($(KERNELRELEASE),)
obj-m := fgpio011.o
else
KDIR := /home/linux-2.6.30/
all:
make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=arm-linux-
clean:
rm -f * *.o *.o *.c *ers
endif
注释:
KDIR := /home/linux-2.6.30/
KDIR 指定开发板内核所在目录。
CROSS_COMPILE=arm-linux- 指定编译器。
其它项目与PC机的一样。
驱动模块编译进内核
相關文章
-
Human Life Like a Poem精美英文赏析
Human Life Like a PoemI think that, from a biological standpoint,human life almost reads like a poem.It has its own rhythm and beat,its inteal cycles of growth and decay.No one can say that a life wit -
英语阅读:African Union Leaders Talk Mali, Chinese Investmen
African leaders met in Ethiopia during the weekend to celebrate the 50th anniversary of their continental alliance and discuss issues such as Chinese investment on the continent as well as the fight a -
高中英语作文:Smart tech makes life simpler
Most of us have been in this situation. You’re halfway to meeting your friends, then you suddenly ask yourself, Did I remember to tu the lights off? For those with smart homes, however, this wou -
readingmanfull英语作文makes
Reading is very important in our life. We can get knowledge through reading. It can not only open our minds but also make us more intelligent. Besides, reading is also one of the most important ways t -
I Am a Little Employee of My Father 国中英语作文
我的爸爸经常“爬格子”,那是他的职业。这个寒假,爸爸在赶一个研究课题。他急需一个打字员帮他把研究成果输入电脑,可直到现在爸爸也没有助手。于是他问我能否帮他这个忙国中作文 ,他答应会给我酬劳。我欣然应允,因为这是 -
阅读的重要性Reading Makes a Full Man英语作文(精选6篇)
在日常的学习、工作、生活中,大家都写过作文吧,作文一定要做到主题集中,围绕同一主题作深入阐述,切忌东拉西扯,主题涣散甚至无主题。写起作文来就毫无头绪?以下是小编为大家收集的阅读的重要性Reading Makes a Full Man英语 -
Daming flies kites in the park教案
教案包括教材简析和学生分析、教学目的、重难点、教学准备、教学过程及练习设计等。下面是小编整理的关于Daming flies kites in the park教案,希望大家认真学习! 【1】Daming flies kites in the park教案 教学 -
英语美文:Remember,a name is for life.
In Sao Paulo, a baby boy is chortling away, unaware that a court is deciding his fate. If it finds in his father's favour, he is in all kinds of trouble. There may be a law in Brazil against givin -
The Bad Effects of Fake Diplomas英语作文
The Bad Effects of Fake DiplomasThere has been a serious epidemic of fake diplomas in some big cities recently. Obviously, its appearance and development involve two parts: the demander and the suppli -
Will Robot Take the Place of Men英语作文
Many years ago, as the development of technology, robot was created to facilitate peoples work. Robot can do many things for men, like it will accept the order and then carry out it. The most obvious