makefile: how to add a prefix to the basename?

前端 未结 1 1044
慢半拍i
慢半拍i 2020-12-13 18:10

I have a list of file path like that:

FILE_PATH := a1.so a2.so bla/a3.so bla/a3.so bla/blo/a4.so....

I need to add a prefix to the basename

相关标签:
1条回答
  • 2020-12-13 18:37

    Look at Make's addprefix function.

    Here is an example we use with addsuffix to place obj files one directory below the source.

    SOURCE += MainThread.cpp
    SOURCE += Blah.cpp
    
    OBJ=$(join $(addsuffix ../obj/, $(dir $(SOURCE))), $(notdir $(SOURCE:.cpp=.o)))
    
    

    From the make manual: 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'. 
    
    0 讨论(0)
提交回复
热议问题