Hello, I am using GNU make version 3.81. It seems that at the Makefile rebuilding stage, if an included makefile is rebuilt as a dependency of another included Makefile with no rule to update the second Makefile, then the first Makefile will not be registered as having been rebuilt for the purposes of checking whether the main Makefile should be re-read or not.
>From the make manual (3.7 How Makefiles Are Remade): "After all makefiles have been checked, if any have actually been changed, `make' starts with a clean slate and reads all the makefiles over again." The file has been changed, even if in an unusual way, so this implies the makefiles should all be re-read. Here's an example: The following is in "rebuild.mk": -- .DEFAULT_GOAL := default file1.mk: echo "ext=c" >file1.mk include file1.mk include file2.mk file2.mk: file1.mk default: dummy.$(ext) echo here -- A file "dummy.c" is in the same directory, as well as an empty file "file2.mk". If we delete file1.mk and run "make -f rebuild.mk", we get the following: -- rebuild.mk:5: file1.mk: No such file or directory echo "ext=c" >file1.mk make: *** No rule to make target `dummy.', needed by `default'. Stop. -- make is expanding $(ext) as the empty string, and not seeing the value in the newly created file1.mk. It appears that file1.mk is being rebuilt from the rule for file2.mk. From "make -d -f rebuild.mk": -- GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for i486-slackware-linux-gnu Reading makefiles... Reading makefile `rebuild.mk'... Reading makefile `file1.mk' (search path) (no ~ expansion)... Reading makefile `file2.mk' (search path) (no ~ expansion)... Updating makefiles.... Considering target file `file2.mk'. [...] No implicit rule found for `file2.mk'. Considering target file `file1.mk'. File `file1.mk' does not exist. Finished prerequisites of target file `file1.mk'. Must remake target `file1.mk'. echo "ext=c" >file1.mk Putting child 0x08095408 (file1.mk) PID 21575 on the chain. Live child 0x08095408 (file1.mk) PID 21575 Reaping winning child 0x08095408 PID 21575 Removing child 0x08095408 PID 21575 from chain. Successfully remade target file `file1.mk'. Finished prerequisites of target file `file2.mk'. Prerequisite `file1.mk' is newer than target `file2.mk'. Must remake target `file2.mk'. Successfully remade target file `file2.mk'. Pruning file `file1.mk'. Considering target file `rebuild.mk'. Looking for an implicit rule for `rebuild.mk'. [...] No implicit rule found for `rebuild.mk'. Finished prerequisites of target file `rebuild.mk'. No need to remake target `rebuild.mk'. Updating goal targets.... Considering target file `default'. File `default' does not exist. Considering target file `dummy.'. File `dummy.' does not exist. [...] -- If however, we add a command for file2.mk which builds file2.mk, then we manage to re-read all the makefiles again (on account of file2.mk being updated). With "file2.mk: file1.mk ; touch file2.mk" in rebuild.mk instead, "make -f rebuild.mk" outputs the following if file1.mk doesn't exist: -- rebuild.mk:5: file1.mk: No such file or directory echo "ext=c" >file1.mk touch file2.mk echo here here -- Output of "make -d -f rebuild.mk" in this case: -- [...] Reading makefiles... Reading makefile `rebuild.mk'... Reading makefile `file1.mk' (search path) (no ~ expansion)... Reading makefile `file2.mk' (search path) (no ~ expansion)... Updating makefiles.... Considering target file `file2.mk'. Considering target file `file1.mk'. File `file1.mk' does not exist. Finished prerequisites of target file `file1.mk'. Must remake target `file1.mk'. echo "ext=c" >file1.mk Putting child 0x08095820 (file1.mk) PID 21595 on the chain. Live child 0x08095820 (file1.mk) PID 21595 Reaping winning child 0x08095820 PID 21595 Removing child 0x08095820 PID 21595 from chain. Successfully remade target file `file1.mk'. Finished prerequisites of target file `file2.mk'. Prerequisite `file1.mk' is newer than target `file2.mk'. Must remake target `file2.mk'. touch file2.mk Putting child 0x08095a78 (file2.mk) PID 21596 on the chain. Live child 0x08095a78 (file2.mk) PID 21596 Reaping winning child 0x08095a78 PID 21596 Removing child 0x08095a78 PID 21596 from chain. Successfully remade target file `file2.mk'. Pruning file `file1.mk'. Considering target file `rebuild.mk'. Looking for an implicit rule for `rebuild.mk'. [...] No implicit rule found for `rebuild.mk'. Finished prerequisites of target file `rebuild.mk'. No need to remake target `rebuild.mk'. Re-executing[1]: make -d -f rebuild.mk GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for i486-slackware-linux-gnu Reading makefiles... Reading makefile `rebuild.mk'... Reading makefile `file1.mk' (search path) (no ~ expansion)... Reading makefile `file2.mk' (search path) (no ~ expansion)... Updating makefiles.... Considering target file `file2.mk'. Considering target file `file1.mk'. Finished prerequisites of target file `file1.mk'. No need to remake target `file1.mk'. Finished prerequisites of target file `file2.mk'. Prerequisite `file1.mk' is older than target `file2.mk'. No need to remake target `file2.mk'. Pruning file `file1.mk'. Considering target file `rebuild.mk'. Looking for an implicit rule for `rebuild.mk'. [...] No implicit rule found for `rebuild.mk'. Finished prerequisites of target file `rebuild.mk'. No need to remake target `rebuild.mk'. Updating goal targets.... Considering target file `default'. File `default' does not exist. Considering target file `dummy.c'. [...] -- Regards, Gavin Smith _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make