Makefile: fix dependency includes

This commit is contained in:
John 2022-04-05 18:06:52 -05:00
parent ef916835e8
commit 9a63c16cd2

View File

@ -1,13 +1,13 @@
# Executable
TARGET := main.out
# Paths to source, dependency, object files
# Paths to source, include, dependency, and object files
SPATH = src
IPATH = inc
DPATH = dep
OPATH = obj
VPATH = $(SPATH) $(OPATH) $(IPATH) $(DPATH)
VPATH = $(SPATH) $(IPATH) $(DPATH) $(OPATH)
# compiler and compiler flags
CC = g++
@ -38,11 +38,11 @@ $(DPATH) $(OPATH):
%.out: $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^
# Make the object and dependency files
$(OPATH)/%.o $(DPATH)/%.d: $(SPATH)/%.cpp
$(OPATH)/%.o: $(SPATH)/%.cpp
$(CC) $(CFLAGS) -MF $(DPATH)/$(@F:.o=.d) -o $@ -c $<
# Don't delete object files:
.PRECIOUS: $(OPATH)/%.o $(DPATH)/%.d
# Don't autodelete object files:
.SECONDARY: $(OPATH)/%.o
# use dependencies when rebuilding
-include $(addprefix $(DPATH)/,$(wildcard *.d))
-include $(wildcard $(DPATH)/*.d)