title: Create dependency files in Makefile
body: <p>I am using a Makefile including  a rule to create a dependency file. The compiler is GCC.</p>
  
  <pre><code>%.d: %.c
      mkdir -p $(@D)
      $(CC) $(CFLAGS) $(CPPFLAGS) -M $&lt; | \
      sed 's,\($(notdir $*)\.o\) *:,$(dir $@)\1 $@: ,' &gt; $@.tmp
      mv $@.tmp $@
  </code></pre>
  
  <p>I am quite new in Makefile technique and I find it a little bit difficult to understand this rule composed of a mixture of several options.<br>
  Can somebody give a simple explanation how this rule works?
  Thanks in advance.</p>