Fatih Arslan
Fatih Arslan

Reputation: 17117

Expansion in Make variables

I have two variables in my Makefile:

archs = i386 x86_64
tarball = foo-i386 foo-x86_64

As you see my second variable is actually based on the first one. But i want something like a regex expansion to use the first variable, like:

tarball = foo-$(archs)

But it doesn't work this way. This expands in GNU Make to:

tarball = foo-i386 x86_64

What's the best way to assign the tarball variable which uses my archs variable ?

Upvotes: 2

Views: 118

Answers (1)

thiton
thiton

Reputation: 36049

When you can rely on GNU make, the foreach function is your friend.

If not, the construction

tarball = $(archs:%=foo-%)

works on some other make's as well. However, it's still on the non-compatible list of features.

Upvotes: 2

Related Questions