Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a newline in Makefile 'foreach' loop

Tags:

makefile

Is it possible to insert a new-line 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.

like image 281
DuneBug Avatar asked Jan 24 '11 23:01

DuneBug


1 Answers

define \n


endef

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

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

like image 59
bobbogo Avatar answered Sep 24 '22 07:09

bobbogo