【问题标题】:${_+_} in a BSD MakefileBSD Makefile 中的 ${_+_}
【发布时间】:2013-04-01 16:42:10
【问题描述】:

我在the FreeBSD Makefile 中找到了${_+_}

BSD Makefiles中${_+_}是什么意思?

【问题讨论】:

  • 我可以告诉你,在 Makefile 命令行开头的 bare + 意味着“即使在 -n 模式下也运行此命令”。您发现的构造似乎与此有关。 _+_ 可能只是一个不寻常的 name 变量,旨在设置为 + 或为空(Make 允许您将几乎任何东西都放在变量名中),但我没有看不到它在哪里设置,所以我能得到的。

标签: unix makefile bsd


【解决方案1】:

${_+_} 指的是一个变量。它在 share/mk/sys.mk 中定义,由 make 进程读取。所以用户 Zack 在他的评论中指出了正确的方向;在某些情况下,此变量会扩展为 + 符号,具体取决于为 make 提供的标志:

.if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
_+_     ?=
.else
_+_     ?=  +
.endif

可以在 this committhis one 的评论中找到这样做的理由,其中引入了符号:

Make make recurse into sub-directories and sub-makes when given
two -n flags.  If only one -n flag is given the old behaviour
is retained (POLA).

【讨论】:

  • 感谢您的友好回答 :)
猜你喜欢
  • 1970-01-01
  • 2011-08-14
  • 1970-01-01
  • 1970-01-01
  • 2013-03-03
  • 2013-08-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多