In my projects, I have a project directory, and 4 subdirs: bin, inc, obj, and src. All source files are in "src", all header files are in "inc".
I am trying to make a makefile to compile all sources into same-name-new-extension objects into "obj" directory, and then link them all together into a final project.out in the "bin" directory. Here is what I have so far:
C_FILES = $(wildcard src/*.c)
OBJ_FILES = $(addprefix obj/,$(notdir $(C_FILES:.cpp=.o)))
LD_FLAGS =
CC_FLAGS = -MMD -c -Wall -lm
BINARY = bin/project.out
all: $(BINARY)
$(BINARY): $(OBJ_FILES)
gcc $(LD_FLAGS) -o $@ $<
OBJ_FILES = $(patsubst $(C_FILES),$(OBJ_FILES),$(SOURCES))
$(CC) $(CC_FLAGS) $< -o $@
-include $(OBJ_FILES:.o=.d)
I'm getting "Missing Separator on line 12" I am new to makefiles, so what are the mistakes I am making? I have tried the GNU makefile tutorial, and I am obviously missing something.