如何注释 Makefile 中的一行?

How to comment a line in a Makefile?

在生成文件中我有一些变量。为了更好地理解,我添加了一些评论:

variable1 = value1     #A comment
variable2 = true       #can be set true or false
variable3 = foo        #can be foo or bar

现在的问题是,变量包含给定文本 文本与 # 之间的所有空格。简单回显的输出显示了问题:

echo "$(variable1) $(variable2) endOfEcho"
value1      true       endOfEcho

如何避免空格被解释为变量的文本?

使用 GNU make:

@echo "$(strip $(variable1)) $(strip $(variable2)) endOfEcho"
value1 true endOfEcho

@echo "$(variable1) $(variable2) endOfEcho"
value1      true        endOfEcho

@echo $(variable1) $(variable2) endOfEcho
value1 true endOfEcho