[bug #63347] make 4.4 change in behavior for sub-make invoked via $(shell)

2022-11-11 Thread Jan Palus
Follow-up Comment #3, bug #63347 (project make):

Just to be clear I don't mind the change with $(shell) now receiving those
vars, what I do mind is that current behavior is selective of which $(shell)s
do receive it. The one in target dependency does not. What I miss is uniform
consistent behavior.


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #63347] make 4.4 change in behavior for sub-make invoked via $(shell)

2022-11-11 Thread Paul D. Smith
Follow-up Comment #2, bug #63347 (project make):

Yes, this is changed in this release; please see the NEWS file
https://git.savannah.gnu.org/cgit/make.git/tree/NEWS?h=4.4#n74 :

* WARNING: Backward-incompatibility!
  Previously makefile variables marked as export were not exported to
commands
  started by the $(shell ...) function.  Now, all exported variables are
  exported to $(shell ...). [...]


If you don't want a sub-make to receive the command-line overrides, you can
reset it via `MAKEOVERRIDES`; see
https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html

An option that I _think_ does what you want might be:


get_conf_var = $(shell $(MAKE) -C lib -s get_conf_var)

all: $(get_conf_var)
@echo $(get_conf_var)

all: private MAKEOVERRIDES :=


Result:

$ make --version | head -n1
GNU Make 4.4

$ make CONF_VAR=bar
called target foo
CONF_VAR=bar
get_conf_var=foo


Another option you can use to be more specific BUT which requires GNU Make 4.4
and won't work with earlier versions is to use the new *let* function
https://www.gnu.org/software/make/manual/html_node/Let-Function.html :

get_conf_var = $(shell $(MAKE) -C lib -s get_conf_var)

all: $(get_conf_var)
@echo $(let MAKEOVERRIDES,,$(get_conf_var))


Personally I think that relying on this odd quirk of shell behavior is hard
for people to understand, especially in the old behavior where you got
different results from running the shell function in different contexts.  It
seems to me that finding a better way that made this requirement more explicit
would be much cleaner.


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #63347] make 4.4 change in behavior for sub-make invoked via $(shell)

2022-11-11 Thread Dmitry Goncharov
Follow-up Comment #1, bug #63347 (project make):

This behavior changed to fix https://savannah.gnu.org/bugs/?10593.
See commit 98da874c43035a490cdca81331724f233a3d0c9a.



___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #63347] make 4.4 change in behavior for sub-make invoked via $(shell)

2022-11-11 Thread anonymous
URL:
  

 Summary: make 4.4 change in behavior for sub-make invoked via
$(shell)
 Project: make
   Submitter: None
   Submitted: Fri 11 Nov 2022 08:21:14 PM UTC
Severity: 3 - Normal
  Item Group: Bug
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: 4.4
Operating System: POSIX-Based
   Fixed Release: None
   Triage Status: None


___

Follow-up Comments:


---
Date: Fri 11 Nov 2022 08:21:14 PM UTC By: Anonymous
It appears that make 4.3 never passed environment down to sub-make if invoked
via shell so ie if make was invoked `make CONF_VAR=foo` then `$(shell $(MAKE)
-C subdir)` would not receive `CONF_VAR=foo`.

Can't tell whether that's expected or not but big advantage of make 4.3 was
that environment was not passed consistently irrespective of where that
`$(shell $(MAKE)...)` occurs.

Now that's no longer the case with make 4.4. Let's consider following
example:

all: $(shell $(MAKE) -C subdir --no-print-directory get_conf_var)
@echo $(shell $(MAKE) -C subdir --no-print-directory get_conf_var)

These two invocations will differ in environment:
- the one producing dependency will not have environment passed
- the one in target body will receive environment

more complete example:

$ cat Makefile
all: $(shell $(MAKE) -C lib --no-print-directory get_conf_var)
@echo CONF_VAR=$(CONF_VAR)
@echo get_conf_var=$(shell $(MAKE) -C lib --no-print-directory 
get_conf_var)

foo bar:
@echo called target $@

$ cat lib/Makefile
CONF_VAR=foo
get_conf_var:
@echo $(CONF_VAR)

$ make-4.3 CONF_VAR=bar
called target foo
CONF_VAR=bar
get_conf_var=foo

$ make-4.4 CONF_VAR=bar
called target foo
CONF_VAR=bar
get_conf_var=bar







___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/