bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #56892] toxic combination of -include and match-anything rules


From: Edward Welbourne
Subject: Re: [bug #56892] toxic combination of -include and match-anything rules
Date: Mon, 16 Sep 2019 09:30:28 +0000

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]