开发者

Taking substring from pathname in Makefile

开发者 https://www.devze.com 2023-02-03 20:05 出处:网络
I currently have the following rule in a Makefile: ../obj/%.o: %.cpp mkdir -p ../obj/$< $(CXX) $(CXXFLAG开发者_运维百科S) $(INCLUDES) $(LIBS) -c $< -o $@

I currently have the following rule in a Makefile:

../obj/%.o: %.cpp
         mkdir -p ../obj/$<
         $(CXX) $(CXXFLAG开发者_运维百科S) $(INCLUDES) $(LIBS) -c $< -o $@
         rmdir ../obj/$<

It takes a cpp file and builds an object file from it, storing the object file under the obj directory. I have multilpe folder hierarchies and this stores the object files within this heirarchy, e.g:

log/internal/log_level.cpp = ../obj/log/internal/log_level.o

As is clear i have hacked make to build the required folders under ../obj. Is there a way I can use make, perhaps through patsubst, whereby I could mkdir with the value of $< not including the filename?


How about $(<D)? Manual.

0

精彩评论

暂无评论...
验证码 换一张
取 消