Multiple lines in make [duplicate]
I am trying to store a multiline string in a variable in make
var=$(shell cat <<End-of-message \
-------------------------------------\
This is line 1 of the message.\
This is line 2 of the 开发者_运维问答message.\
This is line 3 of the message.\
This is line 4 of the message.\
This is the last line of the message.\
-------------------------------------\
End-of-message)
printit:
@echo ${var}
This doesn't work, so I am wondering if this is possible at all. I need to preserve the newlines here and shell is converting them in spaces. Any suggestions?
How about this:
define var
@echo -------------------------------------
@echo This is line 1 of the message.
@echo This is line 2 of the message.
@echo This is line 3 of the message.
@echo This is line 4 of the message.
@echo This is the last line of the message.
@echo -------------------------------------
endef
printit:
${var}
or this:
.PHONY: var
var:
@echo -------------------------------------
@echo This is line 1 of the message.
@echo This is line 2 of the message.
@echo This is line 3 of the message.
@echo This is line 4 of the message.
@echo This is the last line of the message.
@echo -------------------------------------
printit: var
精彩评论