看看Make的addprefix函數。
下面是一個我們使用addsuffix將obj文件放置在 以下目錄下的示例源代碼。
SOURCE += MainThread.cpp
SOURCE += Blah.cpp
OBJ=$(join $(addsuffix ../obj/, $(dir $(SOURCE))), $(notdir $(SOURCE:.cpp=.o)))
從化妝手冊: http://www.gnu.org/software/make/manual/make.html
$(addprefix prefix,names...)
The argument names is regarded as a series of names, separated by whitespace;
prefix is used as a unit. The value of prefix is prepended to the front of each
individual name and the resulting larger names are concatenated with single
spaces between them. For example,
$(addprefix src/,foo bar)
produces the result `src/foo src/bar'.
謝謝啊!我知道addprefix/addsuffix函數,但我錯過了加入函數... – dm76 2009-08-24 14:19:55
我同意dm76的評估,確實這個好答案的關鍵值是join()。 – 2017-07-18 20:04:33