help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Concatenating word lists in GNU make


From: Chad Loder
Subject: Concatenating word lists in GNU make
Date: Fri, 06 Oct 2000 01:14:35 -0700

Hello all. Here's a GNU make puzzle for you.

I have a whitespace-separated list of directories which I need
to treat as individual words, yet at a later point I need to
concatenate them into a PATH style value, where all of the list
elements are separated by only a colon (or semicolon).

For example:

CLASSPATH=/c/foo.jar /c/bar.jar

Needs to be joined into:

/c/foo.jar:/c/bar.jar

I've tried:

$(subst \ ,:,$(CLASSPATH))
$(subst ' ',:,$(CLASSPATH))
$(subst " ",:,$(CLASSPATH))

and so on. I also tried playing around with addprefix and addsuffix
(because I'd be happy with a single leading or trailing colon), but
of course this justs adds the prefix/suffix and preserves whitespace.

I even tried something like:

$(foreach dir,$(CLASSPATH),$(dir):)

but this too seems to preserve internal whitespace.

If worse comes to worse I can write a shell script to do this and
farm it out via $(shell ...), but I was wondering if the builtin
functions provide a way to do this.

        c

P.S. - Also, is there a way to accomplish the reverse? In other
words, tokenizing a string into a wordlist based on 1 or more
token characters? Maybe make needs "explode" and "implode" functions
like they have in other macro languages.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]