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
This commit is contained in:
Chris Lattner 2007-12-31 23:58:31 +00:00
parent b027fa001f
commit e43ba3dce7

View File

@ -1079,23 +1079,28 @@ ifndef DISABLE_AUTO_DEPENDENCIES
# Create .lo files in the ObjDir directory from the .cpp and .c files... # 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) $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG) $(Echo) "Compiling $*.cpp for $(BuildMode) build " $(PIC_FLAG)
$(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\ $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \ $(DEPEND_MOVEFILE)
else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
$(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) $(ObjDir)/%.lo $(ObjDir)/%.o: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG) $(Echo) "Compiling $*.cc for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(MAYBE_PIC_Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ;\ $(Verb) if $(MAYBE_PIC_Compile.CXX) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \ $(DEPEND_MOVEFILE)
else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi
$(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG) $(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
$(Verb) if $(MAYBE_PIC_Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \ $(Verb) if $(MAYBE_PIC_Compile.C) $(DEPEND_OPTIONS) $< -o $(ObjDir)/$*.o ; \
then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \ $(DEPEND_MOVEFILE)
else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi
#--------------------------------------------------------- #---------------------------------------------------------
# Create .bc files in the ObjDir directory from .cpp .cc and .c files... # Create .bc files in the ObjDir directory from .cpp .cc and .c files...