aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-31 23:58:31 +0000
committerChris Lattner <sabre@nondot.org>2007-12-31 23:58:31 +0000
commite43ba3dce745de6e22b1f0e3bd9a39f053349072 (patch)
treeabb62fca275e07d0a379a44a11156895ac46515d
parentb027fa001f16660a231a54ecea6a79f5c7855d7c (diff)
downloadexternal_llvm-e43ba3dce745de6e22b1f0e3bd9a39f053349072.zip
external_llvm-e43ba3dce745de6e22b1f0e3bd9a39f053349072.tar.gz
external_llvm-e43ba3dce745de6e22b1f0e3bd9a39f053349072.tar.bz2
Factor out makefile dependency generation better.
Don't include system headers in the .d files. Don't use $@ in the makefile rules, as there are two possible targets it could resolve to: use the one that we need explicitly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45473 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Makefile.rules23
1 files changed, 14 insertions, 9 deletions
diff --git a/Makefile.rules b/Makefile.rules
index eb827ed..e3a1009 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -1079,23 +1079,28 @@ ifndef DISABLE_AUTO_DEPENDENCIES
# Create .lo files in the ObjDir directory from the .cpp and .c files...
#---------------------------------------------------------
+DEPEND_OPTIONS = -MMD -MP -MF "$(ObjDir)/$*.d.tmp" \
+ -MT "$(ObjDir)/$*.lo" -MT "$(ObjDir)/$*.o" -MT "$(ObjDir)/$*.d"
+
+# If the build succeeded, move the dependency file over. If it failed, put an
+# empty file there.
+DEPEND_MOVEFILE = then $(MV) -f "$(ObjDir)/$*.d.tmp" "$(ObjDir)/$*.d"; \
+ else $(RM) "$(ObjDir)/$*.d.tmp"; exit 1; fi
+
$(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
- $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
- then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
- else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
+ $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
+ $(DEPEND_MOVEFILE)
$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
- $(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\
- then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \
- else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
+ $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
+ $(DEPEND_MOVEFILE)
$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
- $(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \
- then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \
- else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
+ $(Verb) if $(MAYBE_PIC_Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
+ $(DEPEND_MOVEFILE)
#---------------------------------------------------------
# Create .bc files in the ObjDir directory from .cpp .cc and .c files...