aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile25
1 files changed, 16 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 91ab9c02..7743ef52 100644
--- a/Makefile
+++ b/Makefile
@@ -19,14 +19,21 @@ include lib/Makefile.local
%.o: %.c
$(CC) -c $(CFLAGS) $(NOTMUCH_CFLAGS) $< -o $@
-.depends: $(SRCS)
- $(CXX) -M $(CPPFLAGS) $(NOTMUCH_DEPENDS_FLAGS) \
- $(NOTMUCH_CXX_DEPENDS_FLAGS) $^ > $@
--include .depends
-
-CLEAN := $(CLEAN) .depends
+.deps/%.d: %.c
+ @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
+ $(CC) -M $(CPPFLAGS) $(NOTMUCH_DEPENDS_FLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+.deps/%.d: %.cc
+ @set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
+ $(CXX) -M $(CPPFLAGS) $(NOTMUCH_CXX_DEPENDS_FLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+DEPS := $(SRCS:%.c=.deps/%.d)
+DEPS := $(DEPS:%.cc=.deps/%.d)
+-include $(DEPS)
clean:
- rm -f $(CLEAN)
-
-
+ rm -f $(CLEAN); rm -rf .deps