How to comment a line in a Makefile?

2019-07-23 17:25发布

Within a makefile I have a some variables. For a better understanding I added some comments:

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

The problem is now, that the variables contain the given text and all spaces between the text and the #. The output of a simple echo shows the problem:

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

How to avoid the spaces to be interpreted as variable's text?

1条回答
不美不萌又怎样
2楼-- · 2019-07-23 17:46

With 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
查看更多
登录 后发表回答