The following part is commonly found in makefiles.
OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
$(OBJDIR)/%.o : %.c
$(CC) $(DEFS) $(CFLAGS) -o$@ $<
Now my source folder contains both C and C++ files, and I want to link all object files created together using g++. But how do I specify to also also include *.cpp files to get compiled. I mean how do I modify OBJS to also include *.cpp files.
For OBJDIR, maybe, I can do the C++ equivalent like this. I guess the makefile would guess correctly when to use CXX (g++ for C++ files) and when to use CC (gcc for C files).
$(OBJDIR)/%.o : %.cpp
$(CXX) $(DEFS) $(CFLAGS) -o$@ $<
But then, how do I add this rule to OBJS?
$(OBJDIR)/%.o: %.c ... $(OBJDIR)/%.o: %.cpp ...
). – Oliver Charlesworth