我也可以在 elif 中使用 make 条件吗?

Can I use make conditionals with elif too?

我可以用 make's conditionals 做简单的检查,像这样:

var = yes
ifeq $(var) "yes"; then
    echo "yes"
else
    echo "no"
fi

但是文档对 elif 只字未提。我可以像下面那样做吗?

var = yes
ifeq $(var) "yes"; then
    echo "yes"
elifeq $(var) "no"; then
    echo "no"
else
    echo "invalid"
fi

如果不能,是否可能,或者我是否必须设置嵌套条件或使用 test

Can I do it like the following ?

没有。您不能使用 elifeq.

do I have to make nested conditions or use test ?

没有。文档说:

The syntax of a complex conditional is as follows: ... or:

conditional-directive-one
text-if-one-is-true
else conditional-directive-two
text-if-two-is-true
else
text-if-one-and-two-are-false
endif

There can be as many “else conditional-directive” clauses as necessary.

注意这里说的是 else conditional-directive-two。所以,你可以这样写:

var = yes
ifeq ($(var),yes)
    $(info "yes")
else ifeq ($(var),no)
    $(info "no")
else
    $(info "invalid")
endif

请注意您的原始语法不是有效的 makefile 语法。看起来您正在尝试使用 shell 语法:makefile 不是 shell 脚本并且不使用相同的语法。