新聞中心

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

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

        作者: 時間:2018-09-05 來源:網(wǎng)絡(luò) 收藏

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

        本文引用地址:http://www.104case.com/article/201809/388515.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)閉
        主站蜘蛛池模板: 镇平县| 沐川县| 嘉善县| 鞍山市| 子洲县| 虞城县| 东兰县| 开化县| 呼伦贝尔市| 汝城县| 武隆县| 黔南| 闵行区| 东莞市| 雷州市| 治多县| 深州市| 常德市| 阳春市| 济阳县| 湖南省| 兴宁市| 民县| 梅河口市| 南陵县| 泾川县| 宾川县| 兴国县| 玛纳斯县| 芮城县| 赤水市| 沁阳市| 宁安市| 黔西县| 阳信县| 台江县| 永康市| 湘潭县| 康定县| 汉沽区| 伊春市|