diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -570,13 +570,8 @@ # Make the archive #---------------------------------------------------------------------- ifneq "$(ARCHIVE_NAME)" "" -ifeq "$(OS)" "Darwin" -$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS) - $(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) - $(RM) $(ARCHIVE_OBJECTS) -else -$(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj))) -endif +$(ARCHIVE_NAME): $(ARCHIVE_OBJECTS) + $(AR) $(ARFLAGS) $@ $^ endif #---------------------------------------------------------------------- @@ -628,12 +623,24 @@ # Make the precompiled header and compile C++ sources against it #---------------------------------------------------------------------- -#ifneq "$(PCH_OUTPUT)" "" +ifneq "$(PCH_OUTPUT)" "" $(PCH_OUTPUT) : $(PCH_CXX_SOURCE) $(CXX) $(CXXFLAGS) -x c++-header -o $@ $< -%.o : %.cpp $(PCH_OUTPUT) - $(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $< -#endif +endif + +.SUFFIXES: + +%.o:: %.c %.d + $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< + +%.o:: %.cpp %.d $(PCH_OUTPUT) + $(CXX) $(PCHFLAGS) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< + +%.o:: %.m %.d + $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< + +%.o:: %.mm %.d + $(CXX) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $< #---------------------------------------------------------------------- # Automatic variables based on items already entered. Below we create @@ -641,43 +648,21 @@ # that end with .c with .o, and we also create a list of prerequisite # files by replacing all .c files with .d. #---------------------------------------------------------------------- -PREREQS := $(OBJECTS:.o=.d) +PREREQS := $(OBJECTS:.o=.d) $(ARCHIVE_OBJECTS:.o=.d) DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo) ifneq "$(DYLIB_NAME)" "" DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d) DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo) endif -#---------------------------------------------------------------------- -# Rule for Generating Prerequisites Automatically using .d files and -# the compiler -MM option. The -M option will list all system headers, -# and the -MM option will list all non-system dependencies. -#---------------------------------------------------------------------- -%.d: %.c - $(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o - -%.d: %.cpp - @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o - -%.d: %.m - @$(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o - -%.d: %.mm - @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o +# Don't error if a .d file is deleted. +$(PREREQS) $(DYLIB_PREREQS): ; #---------------------------------------------------------------------- # Include all of the makefiles for each source file so we don't have # to manually track all of the prerequisites for each source file. #---------------------------------------------------------------------- -sinclude $(PREREQS) -ifneq "$(DYLIB_NAME)" "" - sinclude $(DYLIB_PREREQS) -endif - -# Define a suffix rule for .mm -> .o -.SUFFIXES: .mm .o -.mm.o: - $(CXX) $(CXXFLAGS) -c $< +include $(wildcard $(PREREQS) $(DYLIB_PREREQS)) .PHONY: clean dsym: $(DSYM)