您的位置 首页 分销

linux kernel 1.0 网络模块代码剖析――目录及Makefile

在linux kernel 1.0的net目录下查看子目录及文件结构:[root@localhost net]# ls -R.:ddi.c inet Makefile socket.c Space.c

在linux kernel 1.0的net目录下检查子目录及文件结构:

[root@localhost net]# ls -R

.:

ddi.c inet Makefile socket.c Space.c unix

./inet:

arp.c datagram.c dev.h eth.h icmp.h ip.c loopback.c packet.c protocol.c raw.c README route.h skbuff.h sock.h tcp.h udp.c utils.c

arp.h dev.c eth.c icmp.c inet.h ip.h Makefile proc.c protocol.h raw.h route.c skbuff.c sock.c tcp.c timer.c udp.h

./unix:

Makefile proc.c sock.c unix.h

能够看到net由ddi.c,socket.c和Space.c三个文件,inet和unix两个目录,还有Makefile组成。

暂时不答理inet和unix目录下的文件,看看Makefile的内容:

# Note! Dependencies are done automagically by ‘make dep’, which also

# removes any old dependencies. DON’T put your own dependencies here

# unless it’s something special (ie not a .c file).

#

# Note 2! The CFLAGS definition is now in the main makefile…

# only these two lines should need to be changed to remove inet sockets.

# (and the inet/tcpip.o in net.o)

SUBDIRS := unix inet

SUBOBJS := $(foreach f,$(SUBDIRS),$f/$f.o)

#SUBOBJS的值为 unix/unix.o inet/inet.o

.c.o:

$(CC) $(CFLAGS) -c $

.s.o:

$(AS) -o $*.o $

.c.s:

$(CC) $(CFLAGS) -S $

#旧式makefile中的隐式规矩界说

#假如编译方针为xx.o:xx.c则主动引证第一个规矩,依此类推

OBJS = Space.o ddi.o socket.o

all: subdirs net.o

net.o: $(OBJS) network.a

$(LD) -r -o net.o $(OBJS) network.a

#将Space.o,ddi.o,socket.o和netowrk.a编译成net.o,net.o再编译进内核中。

network.a: $(SUBOBJS)

rm -f $@

ar rc $@ $(SUBOBJS)

ranlib $@

#将unix/unix.o和inet/inet.o打包成network.a

subdirs: dummy

set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done

#进入各个子目录别离编译unix.o和inet.o

dep:

$(CPP) -M *.c > .depend

set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i dep; done

dummy:

#假的target

#

# include a dependency file if one exists

#

ifeq (.depend,$(wildcard .depend))

include .depend

endif

Makefile 51L, 1023C

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/fenxiao/135625.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部