6

我有一个列出源文件的makefile:(缩短为相关)

SRCFOLDER=src/
SOURCES= main.cpp
OBJECTS=$(SOURCES:.cpp=.o)

我想将字符串连接在一起,但对于SOURCES. 正如您在上面看到的,我这样做是为了OBJECTS,但我想这样做:(伪代码)

foreach(src in SOURCES)
  src = concate(SRCFOLDER, src)

所以如果SOURCESmain.cpp window.cpp,结果就是src/main.cpp src/window.cpp

我试过这个:

SOURCES=$(SOURCES:*=$(SRCFOLDER)/*)

但我收到此错误:

makefile:12: *** Recursive variable `SOURCES' references itself (eventually). Stop.
4

1 回答 1

11
SRCFOLDER := src
SOURCES := main.cpp window.cpp
SOURCES := $(addprefix $(SRCFOLDER)/, $(SOURCES))
于 2012-07-17T02:46:37.483 回答