Re: ?= $(shell ...) re-runs shell in sub-makes when $(origin VAR) is environment (regression in 4.4)
David Boyce <[email protected]> Fri, 29 May 2026 10:19:22 -0400
| Newsgroups | gmane.comp.gnu.make.bugs |
|---|---|
| Message-ID | <CACUHbYOD4DPfNXy0kxugdCEMa9XXd3KFzkpfLJ=87d+33h4bmQ@mail.gmail.com> |
--000000000000b897350652f588a7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I admit I didn't read this old thread or example makefiles closely so I may be missing subtleties but a few responses: > Replacing ?=3D with :=3D (immediate assignment, computed once at top-make parse time) avoids the problem at the cost of breaking command-line variable override. This sounds like a common misunderstanding. *All* variable types are overridable at the command line. People often think they need ?=3D to enabl= e this but :=3D overrides the same (of course the resulting variable is now simply expanded which is a possible consideration). > (the lines below "$(PHASES):" and "inner-%:" must begin with a TAB) In future example makefiles you can use ; to disambiguate the tab issue: foo: bar; recipe > default_TOP :=3D $(shell pwd) I've never understood this pattern. Make has no chdir operator so each individual make process is trapped in its starting cwd (this is a feature). Of course recipes including recursive make can change their cwd but that's the only place it can change and it's a new process. Therefore using $(shell pwd) seems generally a waste of an exec since it's available as $(CURDIR). I understand there might be an interest in tracking prior working dirs in a recursive-make process tree, but in any given make process can there be a difference between $(shell pwd) and $(CURDIR)? David On Thu, May 21, 2026 at 2:38=E2=80=AFAM Basile STARYNKEVITCH < [email protected]> wrote: > On Wed, 2026-05-20 at 18:06 -0400, Paul Smith wrote: > > On Wed, 2026-05-20 at 15:09 +0000, Gunter Woytowitz wrote: > > > will this change be available as an update in the ubuntu resolute > > > repos ? > > > > I have no way of knowing the answer to that: it's up to the Ubuntu > > maintenance team. The GNU project is not involved at all. > > > > However, GNU make 4.4 is easily compilable (e.g. as > /usr/local/bin/make) on Ubuntu or Debian systems. So building your GNU > make could be a solution > > -- > > Basile STARYNKEVITCH > <[email protected]> > 8 rue de la Fa=C3=AFencerie > http://starynkevitch.net/Basile/ > 92340 Bourg-la-Reine > https://github.com/bstarynk > France > https://github.com/RefPerSys/RefPerSys > https://orcid.org/0000-0003-0908-5250 > > --000000000000b897350652f588a7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div id=3D"m_-761400062495151883gmail-:4jl" aria-label=3D"= Message Body" role=3D"textbox" aria-multiline=3D"true" style=3D"direction:l= tr;min-height:85px" aria-controls=3D":4mf" aria-expanded=3D"false">I admit = I didn't read this old thread or example makefiles closely so I may be = missing subtleties but a few responses:<div><br></div><div>>=C2=A0Replac= ing ?=3D with :=3D (immediate assignment, computed once at top-make parse t= ime) avoids the problem at the cost of breaking command-line variable overr= ide. </div><div><br></div><div>This sounds like a common misunderstanding. = *All* variable types are overridable at the command line. People often thin= k they need ?=3D to enable this but :=3D overrides the same (of course the = resulting variable is now simply expanded which is a possible consideration= ).</div><div><br></div><div>>=C2=A0(the lines below "$(PHASES):&quo= t; and "inner-%:" must begin with a TAB)</div><div><br></div><div= >In future example makefiles you can use ; to disambiguate the tab issue:</= div><div><br></div><div>foo: bar; recipe</div><div><br></div><div>>=C2= =A0default_TOP =C2=A0:=3D $(shell pwd)</div><div><br></div><div>I've ne= ver=C2=A0understood this pattern. Make has no chdir operator so each indivi= dual make process=C2=A0is trapped in its starting=C2=A0cwd (this is a featu= re). Of course recipes including=C2=A0recursive make can change their cwd b= ut that's the only place it can change and it's a new process. Ther= efore using $(shell pwd) seems generally a waste of an exec since it's = available as $(CURDIR).</div><div><br></div><div>I understand there might b= e an interest in tracking prior working dirs in a recursive-make process tr= ee, but in any given make process can there be a difference between $(shell= pwd) and $(CURDIR)?</div><div><br></div><div>David</div></div></div><br><d= iv class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, May = 21, 2026 at 2:38=E2=80=AFAM Basile STARYNKEVITCH <<a href=3D"mailto:basi= [email protected]" target=3D"_blank">[email protected]</a>> wr= ote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px= 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 202= 6-05-20 at 18:06 -0400, Paul Smith wrote:<br> > On Wed, 2026-05-20 at 15:09 +0000, Gunter Woytowitz wrote:<br> > > will this change be available as an update in the ubuntu resolute= <br> > > repos ?<br> > <br> > I have no way of knowing the answer to that: it's up to the Ubuntu= <br> > maintenance team.=C2=A0 The GNU project is not involved at all.<br> > <br> <br> However, GNU make 4.4 is easily compilable (e.g. as<br> /usr/local/bin/make) on Ubuntu or Debian systems. So building your GNU<br> make could be a solution<br> <br> -- <br> <br> Basile STARYNKEVITCH=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<br> <<a href=3D"mailto:[email protected]" target=3D"_blank">basile@st= arynkevitch.net</a>><br> 8 rue de la Fa=C3=AFencerie=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 <br> <a href=3D"http://starynkevitch.net/Basile/" rel=3D"noreferrer" target=3D"_= blank">http://starynkevitch.net/Basile/</a>=C2=A0 <br> 92340 Bourg-la-Reine=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 <br> <a href=3D"https://github.com/bstarynk" rel=3D"noreferrer" target=3D"_blank= ">https://github.com/bstarynk</a><br> France=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<br> <a href=3D"https://github.com/RefPerSys/RefPerSys" rel=3D"noreferrer" targe= t=3D"_blank">https://github.com/RefPerSys/RefPerSys</a><br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <a href=3D"h= ttps://orcid.org/0000-0003-0908-5250" rel=3D"noreferrer" target=3D"_blank">= https://orcid.org/0000-0003-0908-5250</a><br> <br> </blockquote></div> --000000000000b897350652f588a7--