什么?=在Makefile中做什么?

时间:2014-04-08 14:58:23

标签: makefile

浏览Makefile,我看到SOMEVAR?=somestuff,我不确定这意味着什么。

任何帮助都将不胜感激。

谢谢!

3 个答案:

答案 0 :(得分:4)

根据GNU Make Manual,只有在当前未使用其他值定义时才设置SOMEVAR

答案 1 :(得分:2)

如果尚未定义,则将值分配给SOMEVAR

答案 2 :(得分:2)

请参阅make的MAN页面:

  

可变分配        make中的变量很像shell中的变量,并且通过传统变量        由所有大写字母组成。

     

变量赋值修饰符        可用于为变量赋值的五个运算符为        如下:

 =       Assign the value to the variable.  Any previous value is overrid-
         den.

 +=      Append the value to the current value of the variable.

 ?=      Assign the value to the variable if it is not already defined.

 :=      Assign with expansion, i.e. expand the value before assigning it
         to the variable.  Normally, expansion is not done until the vari-
         able is referenced.  NOTE: References to undefined variables are
         not expanded.  This can cause problems when variable modifiers
         are used.

 !=      Expand the value and pass it to the shell for execution and
         assign the result to the variable.  Any newlines in the result
         are replaced with spaces.