On Wed, 2022-08-10 at 04:32 +0800, ljh wrote: > make manual / 10.2 Catalogue of Built-In Rules / Linking a single > object file
The example in the manual is wrong. The output you're getting from GNU make is correct. The reason is that the implicit rule that make chooses for the rule: x: y.o z.o is not "%.o : %.c" followed by "% : %.o". Instead, make chooses the default rule "% : %.c" which knows how to create a binary directly from an similarly-named .c file. You'll note in your output that the link line is: g++ ... x.cpp y.o z.o a.o d.o -o x see how you have "x.cpp" on the link line, not "x.o"? And there's no "x.o" in your directory. This may not be what you want, but it's a perfectly valid way to build things. As for the "rm" that's clearly just wrong: since these objects are mentioned as prerequisites they cannot be considered intermediate and won't be deleted. So, the manual example needs to be fixed.