新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > linux kernel 1.0 網(wǎng)絡(luò)模塊代碼分析――目錄及Ma

linux kernel 1.0 網(wǎng)絡(luò)模塊代碼分析――目錄及Ma

作者: 時間:2016-10-08 來源:網(wǎng)絡(luò) 收藏

在linux kernel 1.0的net目錄下查看子目錄及文件結(jié)構(gòu):

本文引用地址:http://m.butianyuan.cn/article/201610/305657.htm

[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的內(nèi)容:

# 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中的隱式規(guī)則定義

#如果編譯目標(biāo)為xx.o:xx.c則自動引用第一個規(guī)則,依此類推

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再編譯進(jìn)內(nèi)核中。

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

#進(jìn)入各個子目錄分別編譯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



關(guān)鍵詞:

評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉