Domanda

I have 3 dirs and want to link an executable against the libraries

I already have the directory list:

DIRS=Math Graph Test

I want to get the library list like this:

LIBS=Math/libMath.a Graph/libGraph.a Test/libTest.a

If I use this:

$(DIRS:%=%/%.a)

I get:

Math/%.a Graph/%.a Test/%.a

GNU Makefile says:

Only the first ‘%’ in the pattern and replacement is treated this way; any subsequent ‘%’ is unchanged.

Here I need 2 occurrences to be replaced, not just the first one.

È stato utile?

Soluzione 2

eventually I used:

LIBS := $(join $(DIRS), $(DIRS:%=/lib%.a))

Altri suggerimenti

You'll have to use a loop:

LIBS := $(foreach D,$(DIRS),$D/lib$D.a)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top