c++ - Using patsubst to convert one path into another -


in order make directory strcuture of project bit more organized want put sourcefiles same modules seperate directory. objectfiles should put obj directory. don't want replicate source tree in obj directory well, i'm looking way remove directory part source file make obj path.

so current version, require obj directory of same layout source directory.

objdir:= obj srcdir:= src  src := propertyfile/propertyfile.cpp otheritems/file.cpp otheritmes/subtree/bla.cpp obj := $(patsubst %.cpp, $(objdir)/%.o, $(src)) 

to make more clear: sources reside in

src/propertyfile/* src/otheritems/* src/otheritmes/subtree/* 

and on.

the objfiles should in obj without intermediate directories. above patsubst, replaces src part obj making i.e. src/propertyfile/propertyfile.cpp obj/propertyfile/propertyfile.o have obj/propertyfile.o

a pointer explanation on how these patterns work , parameters accepts helpfull.

update:

so far made little progress using following line:

obj :=      $(addprefix obj/,$(notdir $(src:.cpp=.o))) 

however build rule doesn't work anymore because names don't match, need pattern works build rule well.

one way achieve using vpath.

another way, like:

obj := ${src:%.cpp=${objdir}/%.o} 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -