2
votes

I currently have the following rule in a Makefile:

../obj/%.o: %.cpp
         mkdir -p ../obj/$<
         $(CXX) $(CXXFLAGS) $(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?

1
I don't understand how this is a C++ question.Lightness Races in Orbit

1 Answers