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)