문제

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.

도움이 되었습니까?

해결책 2

eventually I used:

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

다른 팁

You'll have to use a loop:

LIBS := $(foreach D,$(DIRS),$D/lib$D.a)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top