• GNU make manual 翻译( 一百零二)


    继续翻译

       A phony target should not be a prerequisite of a real target file;if it is, its recipe will be run every time `make' goes to update that file.  As long as a phony target is never a prerequisite of a real target, the phony target recipe will be executed only when the phony target is a specified goal (*note Arguments to Specify the Goals:
    Goals.).
    
       Phony targets can have prerequisites.  When one directory contains multiple programs, it is most convenient to describe all of the programs in one makefile `./Makefile'.  Since the target remade bydefault will be the first one in the makefile, it is common to make this a phony target named `all' and give it, as prerequisites, all the individual programs.  For example:
    
         all : prog1 prog2 prog3
         .PHONY : all
    
         prog1 : prog1.o utils.o
                 cc -o prog1 prog1.o utils.o
    
         prog2 : prog2.o
                 cc -o prog2 prog2.o
    
         prog3 : prog3.o sort.o utils.o
                 cc -o prog3 prog3.o sort.o utils.o

    一个伪目的不应当是一个真的目的的前提条件;如果是,它的片段将会在每次运行make 时被执行。正因为伪目的永远不会是一个真正的目的,所以伪目的的片段才能在仅当其为特殊终点时才获得运行。(*note Arguments to Specify the Goals:Goals)

    伪目的自身可以有前提条件。当一个目录包含多个程序,把所有的程序均包含到一个 ./Makefile中是最为方便的。因为缺省的目的重建会针对第一个目的,把此目的命名为伪目的 all ,让它拥有所有其他单独的程序作为前提条件。例如:

    all : prog1 prog2 prog3
    .PHONY : all

    prog1 : prog1.o utils.o
    cc -o prog1 prog1.o utils.o

    prog2 : prog2.o
    cc -o prog2 prog2.o

    prog3 : prog3.o sort.o utils.o
    cc -o prog3 prog3.o sort.o utils.o

     后文待续

  • 相关阅读:
    如何在谷歌浏览器增加插件
    电脑更换硬盘
    电脑增加内存条
    了解计算机存储器
    Vue ----------- 了解, 展示json 数据
    JSON -------- json与字符串之间的转换
    JSON ------ 创建与访问
    Chartjs 简单使用 ------ 制作sin cos 折线图
    WebStorm ------------ 调整字体大小和背景
    输出正整数的各位数字
  • 原文地址:https://www.cnblogs.com/gaojian/p/2695203.html
Copyright © 2020-2023  润新知