make中有多行

时间:2010-05-13 15:01:13

标签: makefile

我正在尝试将多行字符串存储在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}

这不起作用,所以我想知道这是否可行。我需要在这里保留换行符,shell将它们转换为空格。有什么建议吗?

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:0)

这个怎么样:

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}

或者这个:

.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