新聞中心

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

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

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

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

        本文引用地址:http://www.104case.com/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三個(gè)文件,inet和unix兩個(gè)目錄,還有Makefile組成。

        暫時(shí)不理睬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則自動(dòng)引用第一個(gè)規(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)入各個(gè)子目錄分別編譯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)閉
        主站蜘蛛池模板: 尼勒克县| 百色市| 景东| 赣州市| 兴化市| 策勒县| 汉寿县| 连云港市| 镇雄县| 桐庐县| 建水县| 翁牛特旗| 隆回县| 象州县| 措美县| 黄龙县| 哈尔滨市| 蕉岭县| 南江县| 兴安县| 邹城市| 商丘市| 西峡县| 绥芬河市| 阿拉善左旗| 东城区| 德江县| 闵行区| 北川| 汉阴县| 射阳县| 江川县| 肇州县| 太白县| 桐庐县| 壤塘县| 兴海县| 榆树市| 临海市| 武陟县| 平江县|