bug-make
[Top][All Lists]
Advanced

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

Re: GNU Make 4.3: Makefile rule spooky action at a distance


From: Jeffrey Walton
Subject: Re: GNU Make 4.3: Makefile rule spooky action at a distance
Date: Mon, 5 Oct 2020 15:14:15 -0400

On Sun, Oct 4, 2020 at 9:32 AM Danny Milosavljevic
<dannym@scratchpost.org> wrote:
>
> Hi,
>
> I just got a build failure in lz4.  I've isolated it and made a minimal test 
> case, see below.
>
> This is on GNU Guix on a x86_64 machine.
>
> The reason is that apparently one Makefile rule can unwittingly change how 
> another unrelated rule functions, IF a submake is involved.
>
> To reproduce:
>
> $ cat Makefile
>
> all:
>         $(MAKE) -C foo all
>
> dummy: CFLAGS ?= bar
> dummy:
>
> $ cat foo/Makefile
>
> CFLAGS ?= internal
>
> all:
>         echo $(CFLAGS)
>
> Expected behavior:
>
> $ CFLAGS=ok make
> make -C foo all
> make[1]: Entering directory 'foo'
> echo ok
> ok
> make[1]: Leaving directory 'foo'
>
> Actual behavior:
>
> $ CFLAGS=ok make
> make -C foo all
> make[1]: Entering directory 'foo'
> echo internal
> internal
> make[1]: Leaving directory 'foo'

I think you need to export CFLAGS. Or that is where I would look.
CFLAGS is set in the first shell, but it is not inherited in child
shells.

Or, the top makefile should do something like:

    all:
        $(MAKE) -C foo all CFLAGS=$(CFLAGS)

Jeff



reply via email to

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