How to comment a line in a Makefile?

谁说胖子不能爱 提交于 2019-12-11 08:43:57

问题


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:


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


来源:https://stackoverflow.com/questions/40928674/how-to-comment-a-line-in-a-makefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!