[lldb/test] Simplify Makefile rules for .d files
authorPavel Labath <pavel@labath.sk>
Wed, 15 Jul 2020 14:50:34 +0000 (16:50 +0200)
committerPavel Labath <pavel@labath.sk>
Mon, 20 Jul 2020 13:53:19 +0000 (15:53 +0200)
The sed line in the rules was adding the .d file as a target to the
dependency rules -- to ensure the file gets rebuild when the sources
change. The same thing can be achieved more elegantly with some -M
flags.

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

index b9a6937..43352b6 100644 (file)
@@ -727,28 +727,16 @@ endif
 # and the -MM option will list all non-system dependencies.
 #----------------------------------------------------------------------
 %.d: %.c
-       @rm -f $@
-       @$(CC) -M $(CFLAGS) $< > $@.tmp && \
-       sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-       @rm -f $@.tmp
+       $(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 %.d: %.cpp
-       @rm -f $@
-       @$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
-       sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-       @rm -f $@.tmp
+       @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 %.d: %.m
-       @rm -f $@
-       @$(CC) -M $(CFLAGS) $< > $@.tmp && \
-       sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-       @rm -f $@.tmp
+       @$(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 %.d: %.mm
-       @rm -f $@
-       @$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
-       sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-       @rm -f $@.tmp
+       @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 #----------------------------------------------------------------------
 # Include all of the makefiles for each source file so we don't have