开发者

Multiple lines in make [duplicate]

This question already has answers here: Is it possible to create a multi-line string variable in a Makefile (19 answers) Closed 2 years ago.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜