From: Brian Norris <banorris@uci.edu>
Date: Wed, 21 Nov 2012 02:27:20 +0000 (-0800)
Subject: Makefile: fix dependency generation
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=dacd717b37c9043818e9dbd512a8e77e5ec736a1;p=cdsspec-compiler.git

Makefile: fix dependency generation

- Don't regenerate make.deps for 'make clean' target
- Place the dependency on make.deps at the correct level; all "%.o"
  generations depend on it, not the top-level 'all' target
---

diff --git a/Makefile b/Makefile
index 523709f..c363876 100644
--- a/Makefile
+++ b/Makefile
@@ -21,12 +21,15 @@ program_H_SRCS := $(wildcard *.h) $(wildcard include/*.h)
 program_C_SRCS := $(wildcard *.c) $(wildcard *.cc)
 DEPS = make.deps
 
-all: $(LIB_SO) $(DEPS) tests
+all: $(LIB_SO) tests
 
+$(DEPS): build_deps := 1
 $(DEPS): $(program_C_SRCS) $(program_H_SRCS)
 	$(CXX) -MM $(program_C_SRCS) $(CPPFLAGS) > $(DEPS)
 
+ifeq ($(build_deps),1)
 include $(DEPS)
+endif
 
 debug: CPPFLAGS += -DCONFIG_DEBUG
 debug: all
@@ -41,7 +44,7 @@ $(LIB_SO): $(OBJECTS)
 malloc.o: malloc.c
 	$(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
 
-%.o: %.cc
+%.o: %.cc $(DEPS)
 	$(CXX) -fPIC -c $< $(CPPFLAGS)
 
 PHONY += clean