问题
When using the built-in $(error text) and $(warning text) functions of GNU Make, how can I get line breaks into the error/warning output without acrobatics?
By acrobatics I mean funny methods such as these two:
$(warning $(shell /bin/echo -e "something\nfoo\nbar\nbaz"))
$(warning $(shell /bin/bash -c 'echo -e "something\nfoo\nbar\nbaz"'))
which, btw, didn't work for me with GNU Make 3.81 on Ubuntu 10.04.
Rationale: I want to make the error output in conditional parts (ifeq, ifneq) of my GNUmakefile more readable.
The current workaround for me is to use for each line:
$(warning ...)
and finally for the last line:
$(error ...)
回答1:
Define a line break variable using define/endef and use it as $n like this:
define n
endef
$(warning "something$nfoo$nbar$nbaz")
Note the two blank lines between define and endef
来源:https://stackoverflow.com/questions/17055773/how-to-synthesize-line-breaks-in-gnu-make-warnings-or-errors