如何在最后转义反斜杠以表示 Makefile 中的文字反斜杠?

How to escape a backslash in the end to mean literal backslash in Makefile?

这是我的 Makefile:

SLASH = \

all:
    echo '$(SLASH)'

这是输出:

$ make all
echo ''

$

最后的 \ 表示 Makefile 中的行继续,因此它最终将一个空字符串分配给 SLASH.

如何将文字反斜杠分配给 SLASH

你或许可以使用一个虚拟的“空白”来愚弄 make...

BLANK :=
SLASH = $(BLANK)

all:
    echo '$(SLASH)'

以上给了我...

G.M> make -f how-to-escape-a-backslash-in-the-end-to-mean-literal-backslash-in-makefile.mk
echo '\'
\
G.M>