Re: why make clean triggers other rules
Paul Smith <[email protected]> Tue, 06 May 2025 13:01:16 -0400
| Newsgroups | gmane.comp.gnu.make.general |
|---|---|
| Organization | GNU's Not UNIX! |
| Message-ID | <[email protected]> |
On Wed, 2025-05-07 at 00:51 +0800, lijh.8 wrote: > Correct some of my misunderstanding: > > ``` > %.d: %.c > set -e; rm -f $@; \ > $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ > sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ > rm -f $@.$$$$ > ``` > > the .d file depends on `.c` source file as stated in rule ` %.d: %.c > `. > > the sed command puts the `.d` file as the target of both `.c` and > `.h` files. this makes `.d` file depend on `.h` header file too. > it will regenerate the `.d` file even when the header file is > changed. > ``` > main.o : main.c defs.h > main.o main.d : main.c defs.h > ``` That is correct. But, as said in my first reply, this is an old-fashioned and no longer recommended way to handle prerequisite tracking.