Ben
Ben

Reputation: 2472

In a make file, how do I flatten or iterate over a multi-line list?

I have something along the lines of

define URLS
http://www.foo.com/
http://www.bar.com/
http://www.foo1.com/
endef

How can I flatten that so that it uses spaces instead of linefeeds (I've tried tinkering with $(subst) with little luck) or iterate over each item with a for loop? I realize I can define it differently, but was hoping for a nice clean one-item-per-line solution.

Thanks.

Upvotes: 2

Views: 418

Answers (2)

bobbogo
bobbogo

Reputation: 15493

nicely-spaced := $(strip ${URLS})

Upvotes: 0

Eldar Abusalimov
Eldar Abusalimov

Reputation: 25523

First, you need to define \n, because you can't use it literally.

define \n


endef

Now one may use subst as follows:

URLS := $(subst $(\n), ,$(URLS))

Upvotes: 3

Related Questions