make update makefile

I have a big misunderstanding about make. I thought if I run “make” or “make -f Makefile”, make will check the first target in the makefile and possibly update targets in the dependency chain of the first target. But today, when I ran the make command, I found a missing file was always generated despite the fact that it is not in the dependency chain of the first target, why?

I use the command “mingw32-make –debug” to debug the makefile. I find the following messages when make begins to run:

Reading makefiles…
Updating makefiles….

It indicates make may update the makefile before updating the first target. In fact, if your makefile contains a Makefile target(even not the first target), make will check the dependency chain for the Makefile target to possibly update Makefile. Only after the Makefile is updated does make check the first target. The missing file is in the dependency chain of the Makefile so it gets auto generated every time I run make.

 

If you like my content, please consider buying me a coffee. Buy me a coffeeBuy me a coffee Thank you for your support!

Leave a Reply