Re: why make clean triggers other rules

"lijh.8" via Users list for the GNU implementation of make <[email protected]> Tue, 6 May 2025 21:58:38 +0800
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
Thanks Paul,


I have been following your article


https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/


and put ` CPPFLAGS += -MMD ` in my makefile. And this works.


I have been so confused for years everytime when I read the example in manual
section 4.14 `Generating Prerequisites Automatically`.
So, The rule in 4.14 tries to keep the `.d` files.
When a `.d` file is deleted eg. from command line, the rule will regenerate it.
Am i understanding it correctly?


Also the 4.14 example works with the first two style of the include in makefile.
Why the last two do not work?


-include $(patsubst %.cpp,%.d,$(wildcard *.cpp)) # ok
-include $(sources:.c=.d) # ok
-include $(wildcard *.d) # error
-include *.d # error


Thanks