7
17
2014
10

Linux内核 ext2 文件系统 makefile详解


先给出两个makefile相关链接:

http://www.yayu.org/book/gnu_make/make-04.html

http://www.yayu.org/book/gnu_make/make-06.html

例1:linux-2.6.34.14\fs\ext2\makefile详解​​

#
# Makefile for the linux ext2-filesystem routines.
#

obj-$(CONFIG_EXT2_FS) += ext2.o

ext2-y := balloc.o dir.o file.o ialloc.o inode.o \
	  ioctl.o namei.o super.o symlink.o

ext2-$(CONFIG_EXT2_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
ext2-$(CONFIG_EXT2_FS_POSIX_ACL) += acl.o
ext2-$(CONFIG_EXT2_FS_SECURITY)	 += xattr_security.o
ext2-$(CONFIG_EXT2_FS_XIP)	 += xip.o

1.obj-$(CONFIG_EXT2_FS) += ext2.o  obj- 表示如何编译 y m n分别表示进入内核编译,m 模块编译,n不编译。其中$(CONFIG_EXT2_FS)表示取CONFIG_EXT2_FS值操作,所以ext2的编译方式取决于编译内核是make config时CONFIG_EXT2_FS选定的值。

 

2.ext2-y或者ext2-objs都表示ext2模块(注:-objs用法见例二)

 

3.:= 表示赋值操作

 

4.ext2-y := balloc.o dir.o file.o ialloc.o inode.o \

 ioctl.o namei.o super.o symlink.o 表示ext2.o模块依赖于后面的*.o文件。-y和-objs都表示模块。
 

5.+= 表示追加方式复值:

objects = main.o foo.o bar.o utils.o

objects += another.o

上边的两个操作之后变量“objects”的值成:“main.o foo.o bar.o utils.o another.o”。使用“+=”操作符,就相当于:

objects = main.o foo.o bar.o utils.o

objects := $(objects) another.o

 

6.ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o  表示如果make config步骤中CONFIG_EXT2_FS_XATTR赋值为y,则ext2模块在前面的编译基础上再加上xattr.o xattr_user.o xattr_trusted.o三个文件。

 

7ext2-$(CONFIG_EXT2_FS_POSIX_ACL) += acl.o

ext2-$(CONFIG_EXT2_FS_SECURITY) += xattr_security.o
ext2-$(CONFIG_EXT2_FS_XIP) += xip.o
这三行解释同6
 
 
例2.pcmfs的makefile详解:
#
# Makefile for the Linux pcmfs filesystem routines.
#

obj-m += simplefs.o
simplefs-objs := bitmap.o itree_common.o namei.o inode.o file.o dir.o
KERNELDIR:=/usr/src/linux-2.6.34.14/
PWD:=$(shell pwd)
default:
	make -C $(KERNELDIR) M=$(PWD) modules
clean:
	rm -rf *.o *.mod.c *.ko *.symvers

1.obj-m直接指定编译方式为模块化

2.simplefs-objs := bitmap.o itree_common.o namei.o inode.o file.o dir.o  其中-objs为模块。表示simplefs.o模块依赖后面的文件。

3.KERNELDIR:=/usr/src/linux-2.6.34.14/ 将变量KERNELDIR赋值,为后面提供使用

4.PWD:=$(shell pwd)赋值为当前目录

5.make -C $(KERNELDIR) M=$(PWD) modules

 其中make的 -C表示转换路径,可以再linux下通过man make查看:

        -C dir, --directory=dir

            Change to directory dir before reading the makefiles  or  doing
            anything  else.   If multiple -C options are specified, each is
            interpreted relative to the previous one: -C / -C etc is equiv‐
            alent  to -C /etc.  This is typically used with recursive invo‐
            cations of make.
 
 其中make M=的含义:M不是make中的选项,而是内核根目录下的makefile中使用的变量。M= dir 程序会自动在所指定的dir目录中查找模块代码,将其编译,生成.ko文件
 
 
 
 

 

Category: 文件系统 | Tags: 文件系统;makefile | Read Count: 2616
Avatar_small
Liwovosa 说:
2021年5月06日 15:51

I am always looking for some free kinds of stuff over the internet. There are also some companies which give free samples. But after visiting your blog, I do not visit too many blogs. Thanks. 123movie

Avatar_small
Judi Casino Online T 说:
2021年6月01日 15:24

Judi casino online terbaik. Dapatkan untung yang besar dan bersiap menjadi milyarder hanya di SlotJawara.org. Situs judi online 24 jam terpercaya - agen judi bola online terpercaya deposit pulsa. Terbesar di Indonesia. Segera kunjungi kami.

Avatar_small
China PP woven Shopp 说:
2021年6月10日 20:13

China Non Woven Bags Co., Ltd Is a professional recycle bags manufacturer in China, our main products including non woven bags series, PP woven bags series, PET/RPET bags series, cotton & canvas bags series, nylon & polyester bags series, etc. Our products already well received in Europe, America, Japan, Malaysia, HK, Taiwan and China since 2003.
We have more than 300 employees with modern standard workshop, advanced imported equipment as well as high quality management and technical researchers. All of our products aim to be perfect from design, choice of material, production, packaging, and after-sales service. Based on our principle of "Quality defines existence and management is the key for development", we continually strive to exceed our customers' expectation.
We sincerely hope to cooperate with customers from all over the world to build long-term business relationships,If you have any question of our products, Just feel free to contact us. We will provide you professional advises and are looking forward to receiving your inquiry.
The tenet of our company: Same product, we compare with quality; Same quality we compare with price; Same price, we compare with service; Same service, we compare with speed.

Avatar_small
here 说:
2021年6月11日 00:51

We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work

Avatar_small
Cars in oman 说:
2021年7月20日 19:50

This is very useful post for me. This will absolutely going to help me in my project.

Avatar_small
jasa seo indonesia 说:
2021年8月16日 19:05

Freezing consideration perhaps it is an understanding to create could possibly help everybody else is having troubles searching though My group is some unclear a lot more i am permitted to get details and even communications information at these.

Avatar_small
smm panel 说:
2021年8月22日 19:32

I read a article under the same title some time ago, but this articles quality is much, much better. How you do this..

Avatar_small
data syd 说:
2021年9月08日 15:22

Kami memiliki Data SYD terpercaya yang kami kumpulkan dari sumber terpercaya. Anda yang ingin melakukan betting dengan tepat dan akurat untuk menjamin kemenangan judi online Anda, segera kunjungi website kami, Layanan4D.com Data SYD yang kami berikan akan menolong anda melakukan analisa dan prediksi dengan tepat dan benar. Kami juga hanya merekomendasikan situs judi online terpercaya yang terbukti membayar agar withdraw judi online Anda bisa segera Anda uangkan. Segera kunjungi website kami Layanan4D.com

Avatar_small
rent a car beograd 说:
2021年9月11日 00:11

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful.

Avatar_small
먹튀검증업체 说:
2021年9月14日 23:08

Thanks for the writeup. I definitely agree with what you are saying. I have been talking about this subject a lot lately with my brother so hopefully this will get him to see my point of view. Fingers crossed!


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com