jasmine214--love

          只有當你的內心總是充滿快樂、美好的愿望和寧靜時,你才能擁有強壯的體魄和明朗、快樂或者寧靜的面容。
          posts - 731, comments - 60, trackbacks - 0, articles - 0

          簡單帶子目錄的makefile練習

          Posted on 2012-01-10 21:18 幻海藍夢 閱讀(1689) 評論(1)  編輯  收藏 所屬分類: Linux 、配置管理 、Shell
            開始學linux。我練習寫的第一個帶子目錄的makefile文件。
            1。建立文件夾 wulong
            wulong中含 三個文件夾 include source pro 和makefile文件。
            include 中包含 hai.h頭文件。
            source 中包含 hello.c文件。
            pro 中包含 haia.c haib.c文件。
            
            makefile文件內容有兩種寫法:
            makefile 第一種寫法:
           ?。?br />  CC=gcc #選擇編譯器類型為gcc
            VPATH= include : pr : source #列明文件存放目錄
            
            hello: hello.o haia.o haib.o
             $(CC) -o hello hello.o haia.o haib.o
            hello.o:hello.c hai.h
             $(CC) -c hello.c
            haia.o: haia.c hai.h
             $(CC) -c haia.c
            haib.o: haib.c hai.h
             $(CC) -c haib.c
            .PHONY: clean
            clean:
             rm hello $(obj)
           ?。?br />  
            
            
            makefile第二種寫法(簡化版):
            //********************************
            CC=gcc #選擇編譯種類
            
            VPATH= include : pr : source #在include pr source 三目錄下查找文件
            
            obj= hello.o haia.o haib.o #
            
            hello:$(obj) #
             $(CC) -o hello $(obj)
            
            $(obj): hai.h
            
            .PHONY: clean
            clean:
             rm hello $(obj)
           ?。?br />  
            
            hai.h文件內容為:
            //************************
            #include "stdio.h"
            extern void haiprinta();
            extern void haiprintb();
            //****************
            
            hello.c內容為:
           ?。?br />  #include "../include/hai.h"
            
            int main(void)
            {
            haiprinta();
            haiprintb();
            return 0;
            }
           ?。?br />  
            haia.c內容為:
            //************
            #include "../include/hai.h"
            
            void haiprinta()
            {
            printf("hai aaaaaaaaaa\n");
            }
           ?。?br />  
            
            haib.c內容為:
           ?。?br />  #include "../include/hai.h"
            
            void haiprintb()
            {
            printf("haib bbbbbbbbbbbbbb\n");
            }
            //*******************
            
            2。make 調用makefile生成 可執行文件 hello
            
            3. 運行 hello顯示打印結果:
            [HAI@localhost wulong]$ ./hello
            hai aaaaaaaaaa
            haib bbbbbbbbbbbbbb
            [HAI@localhost wulong]$
            
            到此結束,恭喜!

          原文:
          http://blog.tianya.cn/blogger/post_show.asp?BlogID=2058037&PostID=17326631

          Feedback

          # re: 簡單帶子目錄的makefile練習[未登錄]  回復  更多評論   

          2014-06-24 14:11 by elaine
          您好,我想單獨請教一下visualsvn server與subversion的區別,既然visualsvn server集成了subversion,為什么還有那么多的人在用subversion?
          主站蜘蛛池模板: 乌拉特前旗| 淳安县| 卢龙县| 洛隆县| 涡阳县| 博罗县| 绥江县| 安岳县| 乐业县| 永丰县| 泌阳县| 宜兴市| 闵行区| 恭城| 汨罗市| 莱州市| 康马县| 苏州市| 峨边| 星子县| 双柏县| 怀来县| 英德市| 宜兰县| 桐柏县| 兰坪| 永济市| 涟源市| 仪陇县| 白山市| 光山县| 雷波县| 岗巴县| 晴隆县| 沽源县| 和政县| 商南县| 禹州市| 宁安市| 枣强县| 华阴市|