在 Makefile 中定义了一个print函数,它将打印文本作为参数然后打印出来。我的问题是如何将逗号字符作为文本部分传递来打印它?例如,下面是相关的 makefile 部分,其中逗号不可打印。
print = echo '$(1)'
help:
@$(call print, He lives in Paris, does not he?)
Run Code Online (Sandbox Code Playgroud)
现在,如果像这样运行 makefile:
$ make help
Run Code Online (Sandbox Code Playgroud)
它打印
$ He lives in Paris
Run Code Online (Sandbox Code Playgroud)
代替
$ He lives in Paris, does not he?
Run Code Online (Sandbox Code Playgroud)
我知道在 makefile 中逗号用作单独的参数,但是如何使其可打印。我使用不同的转义字符组合将逗号作为文本消息传递,\, /, $$, ',' "," 但没有任何效果
ogu*_*ail 11
手册上说:
逗号和不匹配的括号或大括号不能出现在书面参数的文本中;前导空格不能出现在第一个参数的文本中。这些字符可以通过变量替换放入参数值中。
因此,您需要将逗号放入变量中,并在参数中使用它。例如:
print = echo '$(1)'
comma:= ,
help:
@$(call print,He lives in Paris$(comma) does not he?)
Run Code Online (Sandbox Code Playgroud)