Update of bug #61955 (project make): Item Group: Bug => Documentation
_______________________________________________________ Follow-up Comment #1: You say you have a makefile that you "always want rebuilt", but that's not really true. What you actually want is to rebuild the makefile exactly one time every time you run the make command. When make re-execs itself to reload makefiles, no state is preserved from the previous invocation (other than MAKE_RESTARTS). So, the second instance of make has no idea that the first instance already rebuilt the target, other than due to normal methods of checking timestamps. If you achieved the goal of "always rebuilding" the makefile, then make would recurse forever rebuilding the makefile and re-exec'ing itself. Each instance would say: do I need to update test.mk? And each time the answer would be "yes", so it would update it then re-exec itself, and that instance would do the same thing. > note how test.mk is generated but MAKE_RESTARTS is not set. Make has a special case for PHONY included makefiles; the comments say: Check for makefiles that are either phony or a :: target with commands, but no dependencies. These will always be remade, which will cause an infinite restart loop, so don't try to remake it I see that this is not documented in the manual so that should be fixed; I will convert this into a documentation bug. In the next release of GNU make this situation is noted in a debug message: Makefile 'test.mk' might loop; not remaking it. > sometimes Make restarts more than one time, which is unexpected. No, it's completely expected. In fact in a perfect system make would recurse forever and never stop, but in fact in most systems today make is able to restart itself so fast that the timestamp of the FORCE target (which is "now") is the same as the timestamp on the file and once that happens make decides that the included file does not get remade and does not re-exec. If you want the included file to be remade exactly one time, then you should do that. One way is to ensure that the makefile doesn't exist the first time, and only that time, something like: ifeq ($(MAKE_RESTARTS),) _ := $(shell rm -f test.mk) endif include test.mk ... test.mk: ; touch $@ _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?61955> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/