简体   繁体   English

Makefile变量扩展语法

[英]Makefile variable expansion syntax

Please explain how does this TARGET get expanded? 请说明此TARGET如何扩展?

PROJECT=helloworld
TARGET = $(PROJECT:=.so)

For example, I have generated helloworld.so.1.2.3, helloworld.so.1 and helloworld.so 例如,我生成了helloworld.so.1.2.3,helloworld.so.1和helloworld.so

This would get messy in the comments, reiterating the description from docs with this example. 这将使注释变得混乱,在此示例中重申文档中的描述。 For: 对于:

PROJECT=helloworld
TARGET = $(PROJECT:=.so)

Value of $(TARGET) would be helloworld.so . $(TARGET)将是helloworld.so As an empty string '' at the end of the word would gets replaced with .so . 作为空字符串,单词末尾的''将被替换为.so This "end of a word" is the difference from: 这个“单词结尾”与以下内容的区别:

TARGET = $(PROJECT).so

With PROJECT being helloworld , the resulting value would look the same, but call make PROJECT="hello world" and in case of the former you end up with hello.so and world.so in TARGET , for the latter, it would be "hello world.so" . PROJECThelloworld ,结果值将相同,但调用make PROJECT="hello world" ,如果是前者, world.soTARGEThello.soworld.so ,对于后者,它将为"hello world.so" Or to quote the docs: 或引用文档:

$(var:a=b)' ... replace every a at the end of a word with b ... “at the end of a word”, we mean that a must appear either followed by whitespace or at the end of the value in order to be replaced $(var:a=b)' ...将单词末尾的每个a替换为b ...“单词末尾”,我们的意思是a必须出现在空格之后或在末尾该值以便被替换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM