Makefile ${if ... , ...} 语法
Makefile ${if ... , ...} syntax
在某些 Makefile 中发现类似这样的语法
${if ${VERBOSE},-DVERBOSE=true} ${if $G,-G "$G"}
我能猜到它的作用,但找不到文档。
有人可以为此指出正确的 name/docs 吗?
根据正确的观察进行编辑,我没有指向确切的正确位置。
条件通常使用 ifeq/ifneq/ifdef/ifndef 指令(或者 if function 事实证明是这种情况)。请参阅 Makefile 的条件部分,第 7 节中的指令或第 8.4 节中的 if 函数 https://www.gnu.org/software/make/manual/
直接取自那里:
$(if condition,then-part[,else-part])
The if function provides support for conditional expansion in a
functional context (as opposed to the GNU make makefile conditionals
such as ifeq (see Syntax of Conditionals).
The first argument, condition, first has all preceding and trailing
whitespace stripped, then is expanded. If it expands to any non-empty
string, then the condition is considered to be true. If it expands to
an empty string, the condition is considered to be false.
在某些 Makefile 中发现类似这样的语法
${if ${VERBOSE},-DVERBOSE=true} ${if $G,-G "$G"}
我能猜到它的作用,但找不到文档。 有人可以为此指出正确的 name/docs 吗?
根据正确的观察进行编辑,我没有指向确切的正确位置。
条件通常使用 ifeq/ifneq/ifdef/ifndef 指令(或者 if function 事实证明是这种情况)。请参阅 Makefile 的条件部分,第 7 节中的指令或第 8.4 节中的 if 函数 https://www.gnu.org/software/make/manual/
直接取自那里:
$(if condition,then-part[,else-part])
The if function provides support for conditional expansion in a functional context (as opposed to the GNU make makefile conditionals such as ifeq (see Syntax of Conditionals).
The first argument, condition, first has all preceding and trailing whitespace stripped, then is expanded. If it expands to any non-empty string, then the condition is considered to be true. If it expands to an empty string, the condition is considered to be false.