开发者

Add a newline in Makefile 'foreach' loop

Is it possible to insert a new-li开发者_如何学编程ne to be executed within a foreach loop in a Makefile?

Currently, I have the following:

$(foreach my_lib,$(MY_LIBS),$(call my_func,results,boxer,$(my_lib)))

Now, assuming that I have:

MY_LIBS = lib1 \
          lib2

The above foreach loop would evaluate to:

lib1 lib2

I would like this to evaluate to:

lib1
lib2

Is it possible to insert a newline in the foreach loop to accomplish this?

Thank you.


define \n


endef

$(error Here is a message${\n}with embedded${\n}newlines.${\n}${\n}hooray!)

You can use ${\n} in things like $(subst...).


You could do this by using

define MY_LIBS
lib1
lib2
endef

In more complex cases, where you want to generate multiline makefile commands from the loop, you will need to use the eval function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜