I have the following Makefile
rules:
DIR = src
SOURCES = $(shell find $(DIR) -name "*.cpp")
OBJS := $(SOURCES:.cpp=.o)
With this definition all my .o
files are located in the same directories (and sub-directories) as their .cpp
counterparts. Such allocation principle turns the project directory into a mess very soon (with 50+ files). I would like to make a new specific folder for .o
files and place them there. I need to write a make-rule that will convert every .o
file name like the following:
foo/bar/test.o —> objects/foo-bar-test.o
How can I create such a rule in Makefile
? Thanks in advance!