如何在GNU Make的警告或错误中合成换行符? [英] How to synthesize line breaks in GNU Make warnings or errors?

查看:94
本文介绍了如何在GNU Make的警告或错误中合成换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用b 内置$(error text)$(warning text)函数时GNU Make 的代码,如何在不使用杂技的情况下将换行符插入错误/警告输出?

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"'))

顺便说一句,它不适用于Ubuntu 10.04上的GNU Make 3.81.

which, btw, didn't work for me with GNU Make 3.81 on Ubuntu 10.04.

合理性:我想使GNUmakefile的条件部分(ifeqifneq)中的错误输出更具可读性.

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 ...)

最后一行:

$(error ...)

推荐答案

使用define/endef定义换行符,并将其用作$ n,如下所示:

Define a line break variable using define/endef and use it as $n like this:

define n


endef

$(warning "something$nfoo$nbar$nbaz")

请注意define和endef之间的两个空白行

Note the two blank lines between define and endef

这篇关于如何在GNU Make的警告或错误中合成换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆