How to synthesize line breaks in GNU Make warnings or errors?

旧街凉风 提交于 2019-12-04 00:32:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!