David Boyce (14 September 2019 22:28) wrote, on <https://savannah.gnu.org/bugs/?56892>: > I'm not saying this is a bug necessarily but want to submit it for > some sort of resolution. I an into an infinite loop situation > recently. On my advice, in a very old and complex recursive makefile > suite (not of my design or under my ownership) a co-worker added a > construct like the following: > > -include foobar.mk > foobar ?= XYZ > > The idea is that foobar.mk would be a one-line include file which > assigns the "foobar" variable if it exists and if not we fall back to > the default value "XYZ". This is simple and solved his problem in unit > testing but when plugged into the large old suite it resulted in an > infinite loop. > > The reason is twofold: (a) if an included makefile doesn't exist make > will try to run a recipe to create it and (b) somewhere deep in this > makefile suite was a match-anything rule. From here it's obvious: make > went looking for a recipe that claimed to be able to make foobar.mk, > landed on the match-anything rule which does a recursive make > invocation (and does not create foobar.mk), and we're off to the races > with an infinite make loop.
You can probably work round this by adding a wilfully failing rule, foobar.mk: @echo "$@ can be hand-created to set foobar" >&2 false IIUC, since this rule is more specific than the match-anything, make shall use it instead, fail, and happily get on with not caring that the -include didn't happen. The echo is, of course, optional. Eddy. _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make