I have the following setup for my c++ project:
in the src-folder, there are *.cpp and corresponding *.h files and in the obj-folders I want to have my .o-files.
All right, you asked for it.
1: Your collect_sources:... include sources
is glorious Rube Goldberg hackery. Just do this:
SRCS = $(wildcard ./src/*.cpp)
And if you want to confirm it by eye, you can do this:
$(info $(SRCS))
2:
clear_dependencies:
echo "" > $(DEP);
Just for the sake of aesthetics, let's fix this.
clear_dependencies:
$(RM) $(DEP);
3:
$(SRCDIR)/%.cpp:
@$(CXX) $(DEPFLAGS) -MT \
"$(subst $(SRCDIR),$(OBJDIR),$(subst $(EXT_SRC),$(EXT_OBJ),$$file))" \
$(addprefix ,$$file) >> $(DEP);
This will take some work. First the immediate problem: the target is a real file which exists, and the rule has no prerequisites. Therefore the rule will not be run (I have no idea why it worked for you in a previous version, maybe something else was different). As a temporary fix I suggest we switch to a static pattern rule and PHONY targets:
.PHONY:$(SRCS)
$(SRCS) : $(SRCDIR)/%.cpp:
@$(CXX) $(DEPFLAGS) -MT \
...
See if all that works, then we can tackle the big stuff.