summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/.gitignore2
-rw-r--r--crawl-ref/source/makefile30
2 files changed, 21 insertions, 11 deletions
diff --git a/crawl-ref/.gitignore b/crawl-ref/.gitignore
index 9ce18d9569..57f18654c6 100644
--- a/crawl-ref/.gitignore
+++ b/crawl-ref/.gitignore
@@ -38,6 +38,7 @@ mapgen.log
# Makefile-generated junk
makefile.dep
+/source/*.d
/source/.contrib-ok
/source/.contrib-libs
/source/compflag.h
@@ -53,6 +54,7 @@ makefile.dep
# Level-compiler generated files.
/source/util/*.cc
+/source/util/*.d
/source/util/*.h
# Generated by ./dolinks.sh
diff --git a/crawl-ref/source/makefile b/crawl-ref/source/makefile
index 8fe258f5d9..498384cb29 100644
--- a/crawl-ref/source/makefile
+++ b/crawl-ref/source/makefile
@@ -564,24 +564,29 @@ test:
##########################################################################
# Dependencies
-DEPENDENCY_MKF := makefile.dep
-
ifeq ($(shell which fastdep 2> /dev/null),)
-depend: $(OBJECTS:.o=.cc)
- rm -f $(DEPENDENCY_MKF).tmp
- @for i in $^; do \
- echo ' ' DEP $$i; \
- $(CXX) -MM $(CFLAGS) $(CFLAGS_L) $$i >>$(DEPENDENCY_MKF).tmp 2>/dev/null; \
- done
- mv -f $(DEPENDENCY_MKF).tmp $(DEPENDENCY_MKF)
+
+%.d: %.cc
+ $(QUIET_DEPEND)$(CXX) -MM $(CFLAGS) $(CFLAGS_L) $< > $@
+
+depend: $(OBJECTS:.o=.d)
+
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
+-include $(OBJECTS:.o=.d)
+endif
+endif
+
else
+
+DEPENDENCY_MKF := makefile.dep
+
depend: $(DEPENDENCY_MKF)
makefile.dep: .contrib-ok
%.dep: $(OBJECTS:.o=.cc)
$(QUIET_DEPEND)fastdep $(DEFINES) $(INCLUDES) $(OBJECTS:.o=.cc) > $@
-endif
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
@@ -589,6 +594,9 @@ ifneq ($(MAKECMDGOALS),distclean)
endif
endif
+endif
+
+
.PHONY: compflag.h build.h version.cc
# This information is included in crash reports, and is printed with
@@ -668,7 +676,7 @@ endif
clean:
+$(MAKE) -C $(UTIL) clean
- $(RM) *.o *.ixx build.h compflag.h .contrib-libs .contrib-ok
+ $(RM) $(OBJECTS) $(OBJECTS:.o=.d) *.ixx build.h compflag.h .contrib-libs .contrib-ok
clean-contrib:
+$(MAKE) -C contrib clean