From 9a63c16cd20f721ea4029a97cb2c5ce21a7caded Mon Sep 17 00:00:00 2001 From: John Breaux Date: Tue, 5 Apr 2022 18:06:52 -0500 Subject: [PATCH] Makefile: fix dependency includes --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9de0d73..acff04f 100644 --- a/Makefile +++ b/Makefile @@ -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)