I\'m reading Managing Projects with GNU Make, and found this example in Chapter 2.7 - Automatic Dependency Generation. The Author says their from the GNU manual:
<
Addressing the question: Why do a redirect of the file into sed?
If you do:
@$(CC) -M $(CPPFLAGS) $< | sed 's|:| $*.d : |' > $@;
and the compilation fails (errors out and generates no output), you will create an empty target file. When make
is run again, it will see the newly created empty file and not regenerate it, leading to build errors. Using intermediate files is a common defensive strategy to avoid accidentally created an empty target.