zoukankan      html  css  js  c++  java
  • GNU make manual 翻译( 一百八十四)

    继续翻译

    7.3 Conditionals that Test Flags
    ================================
    
    You can write a conditional that tests `make' command flags such as
    `-t' by using the variable `MAKEFLAGS' together with the `findstring'
    function (*note Functions for String Substitution and Analysis: Text
    Functions.).  This is useful when `touch' is not enough to make a file
    appear up to date.
    
       The `findstring' function determines whether one string appears as a
    substring of another.  If you want to test for the `-t' flag, use `t'
    as the first string and the value of `MAKEFLAGS' as the other.
    
       For example, here is how to arrange to use `ranlib -t' to finish
    marking an archive file up to date:
    
         archive.a: ...
         ifneq (,$(findstring t,$(MAKEFLAGS)))
                 +touch archive.a
                 +ranlib -t archive.a
         else
                 ranlib archive.a
         endif
    
    The `+' prefix marks those recipe lines as "recursive" so that they
    will be executed despite use of the `-t' flag.  *Note Recursive Use of
    `make': Recursion.

    7.3 测试标志的条件式
    ================================

    你可以写一个测试 make 命令标志的条件式,如通过使用findstring函数处理变量 MAKEFLAGS 来测试标志 -t (*note Functions for String Substitution and Analysis: Text Functions.)。

    findstring 函数决定是否一个字符串作为子串出现在另一个字符串中。如果你想要测试 -t 标志,使用t 作为findstring的第一个参数,MAKEFLAGS 作为另一个参数。

    例如,这里有一个如何使用 ranlib -t 来 完成 标记某个库为最新的例子:

    archive.a: ...
    ifneq (,$(findstring t,$(MAKEFLAGS)))
    +touch archive.a
    +ranlib -t archive.a
    else
    ranlib archive.a
    endif

    +前缀标记那些片段行为递归,因此无论是否使用了-t 标记,它们都将会被执行。*Note Recursive Use of make: Recursion.

    后文待续

  • 相关阅读:
    OData – Query to Expression
    ASP.NET Core Library – Hangfire
    ASP.NET Core Library – Nager.PublicSuffix
    EF Core – Unit of Work, DbContext, Transaction 概念解释
    ASP.NET Core – Program.cs and Startup.cs 小笔记
    OData – OData vs GraphQL
    Fluent Builder 模式
    C# – 冷知识 (新手)
    ASP.NET Core Library – scriban (Template Engine)
    The "蛋炒饭" in microsoft must cost you ten yuan RMB!
  • 原文地址:https://www.cnblogs.com/gaojian/p/2716181.html
Copyright © 2011-2022 走看看