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

          Makefile學習

          Posted on 2010-07-16 20:01 beauty9235 閱讀(278) 評論(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目錄執行clean目標
                  $(MAKE) -C ./hello hello #切換到hello目錄執行hello目標
                  $(MAKE) -C ./hello $@ #切換到hello目錄執行install目標
          all clean:
          ifneq ($(wildcard hell),) #如果有hell這個文件就執行里面的動作
                  $(MAKE) -C ./bin $@ #切換到hello目錄執行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);
          }










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


          網站導航:
           
          主站蜘蛛池模板: 高邑县| 衡水市| 邓州市| 山东| 香格里拉县| 咸阳市| 通渭县| 永康市| 嘉义市| 吴川市| 彩票| 阳信县| 托克逊县| 绥德县| 紫阳县| 台南县| 特克斯县| 肃南| 宝丰县| 盐亭县| 彭泽县| 芜湖市| 分宜县| 体育| 康马县| 广德县| 苏尼特左旗| 永安市| 三河市| 汝南县| 托克逊县| 津市市| 大宁县| 九寨沟县| 昌图县| 松溪县| 湟源县| 临江市| 崇仁县| 安义县| 云安县|