posts - 23, comments - 0, trackbacks - 0, articles - 3
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          Makefile學習

          Posted on 2010-07-16 20:01 beauty9235 閱讀(279) 評論(0)  編輯  收藏
          lxq@lxq:~/tmp$ tree
          .
          |-- Makefile
          |-- bin
          |   `-- Makefile
          |-- hello
          |   |-- Makefile
          |   |-- hello
          |   `-- hello.c
          `-- tmp

          3 directories, 5 files


          cat Makefile
          SRCBASE := $(shell pwd) #獲取當前目錄
          ELEASEDIR := $(shell (cd $(SRCBASE)/.. && pwd -P))
          print:
                  echo ${ELEASEDIR}
          install: all
                  install -d ${ELEASEDIR}/tmp
                  $(MAKE) -C ./hello clean #切換到hello目錄執(zhí)行clean目標
                  $(MAKE) -C ./hello hello #切換到hello目錄執(zhí)行hello目標
                  $(MAKE) -C ./hello $@ #切換到hello目錄執(zhí)行install目標
          all clean:
          ifneq ($(wildcard hell),) #如果有hell這個文件就執(zhí)行里面的動作
                  $(MAKE) -C ./bin $@ #切換到hello目錄執(zhí)行all\clean目標
          endif
          .PHONY: all clean install

          cat hello/Makefile
          clean:
          ifneq ($(wildcard hello),)
                  rm hello
          endif
          hello:
                  gcc -o hello hello.c
          install:
                  -cp hello ../bin/

          cat hello/hello.c
          #include <stdio.h>
          int main()
          {
                  printf("hello");
                  exit(0);
          }










          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 惠水县| 射洪县| 土默特左旗| 衡山县| 福贡县| 泽库县| 金坛市| 郧西县| 营口市| 南川市| 子长县| 都匀市| 长顺县| 桑植县| 双峰县| 莱阳市| 安陆市| 扎赉特旗| 承德市| 额尔古纳市| 五莲县| 淮南市| 彭阳县| 剑川县| 盐城市| 通道| 广南县| 内乡县| 秦皇岛市| 博白县| 靖远县| 庆安县| 乐陵市| 开阳县| 嘉义县| 库尔勒市| 同江市| 蛟河市| 虎林市| 建德市| 望都县|