I realise this is a commong query, but I've spent hours looking at previous answers but am still at a loss. I don't have a huge amount of experience with makefiles and am finding it difficult to follow the examples.
I have the following makefile:
CC=g++
CFLAGS=-c -Wall
LDFLAGS= -lSDL2 -lSDL2_image -lSDL2_ttf
SOURCES=main.cpp hello.cpp factorial.cpp
OBJS=$(SOURCES:%.cpp=%.o)
EXECUTABLE=hello
FULLOBJS = $(addprefix obj/,$(OBJS))
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@
.cpp.o:
$(CC) -MD -I. $(CFLAGS) $< -o $@
clean:
-rm -rf $(OBJS) $(EXECUTABLE) $(OBJS:%.o=%.d)
-include $(OBJS:%.o=%.d)
Which works as I'd like. However, it would be even better if I was able to neatly organise the .h .cpp .o and .b files into /header/ /source/ and /object/ relative subdirectories. Please could you explain to me how to do so?
Thanks very much