通常,make组合多个连续的空格字符。有时这种行为是不需要的。对于这种情况,这是示例:
.PHONY: help
help:
$(info Usage: make [command] [VARIABLES])
$(info )
$(info command1 ..... Do what command1 does and)
$(info let the sentence continue.)
$(info command2 ..... Description of command2)
Usage: make [command] [VARIABLES]
command1 ..... Do what command1 does and
let the sentence continue.
command2 ..... Description of command2
Usage: make [command] [VARIABLES]
command1 ..... Do what command1 does and
let the sentence continue. # Not aligned with "Do" in line above
command2 ..... Description of command2
换句话说,有没有办法在make中对齐或引用空格?
答案 0 :(得分:1)
有一个老技巧:
EMPTY=
SPACE=$(EMPTY) $(EMPTY)
所以,在你的情况下:
.PHONY: help
EMPTY=
SPACE=$(EMPTY) $(EMPTY)
help:
$(info Usage: make [command] [VARIABLES])
$(info )
$(info command1 ..... Do what command1 does and)
$(info $(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)$(SPACE)let the senten\
ce continue.)
$(info command2 ..... Description of command2)
答案 1 :(得分:1)
第一个想法:不要在配方中使用$(info ...)
。而是使用像echo
等shell命令。然后你可以使用引用等来保留空格。
第二个想法,使用define
变量定义来包含完整的内容:
define USAGE
Usage: make [command] [VARIABLES]
command1 ..... Do what command1 does and
let the sentence continue.
command2 ..... Description of command2
endef
.PHONY: help
help: ; $(info $(value USAGE))