[bug #58341] MAKEFLAGS in the makefile contains only simple options

2021-09-05 Thread Paul D. Smith
Update of bug #58341 (project make):

  Status:None => Fixed  
 Assigned to:None => psmith 
 Open/Closed:Open => Closed 
Operating System:None => Any
   Fixed Release:None => SCM
   Triage Status:None => Medium Effort  

___

Follow-up Comment #2:

I've pushed a fix for this to Git.  It will be available in the next release
of GNU make.

___

Reply to this item at:

  

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




[bug #58341] MAKEFLAGS in the makefile contains only simple options

2021-04-18 Thread Paul D. Smith
Update of bug #58341 (project make):

 Summary: `make --debug` does not set 'd' in MAKEFLAGS =>
MAKEFLAGS in the makefile contains only simple options

___

Follow-up Comment #1:

I've retitled this issue because I've discovered that when examining the
MAKEFLAGS variable from within the makefile, only the simple flags are
available, like -k, -r, etc.  None of the flags that take arguments are
available.

For example:


echo '$(info MAKEFLAGS=$(MAKEFLAGS))' | make -f- -k -I/tmp


Shows:


MAKEFLAGS=k


but no sign of the -I/tmp option.

If you examine the value of MAKEFLAGS in the context of a recipe as it is
passed to a sub-make, it contains all the content that you'd expect:


echo 'all:;@echo MAKEFLAGS=$(MAKEFLAGS)' | make -f- -k -I/tmp
MAKEFLAGS=k -I/tmp


so it's only while the makefiles are being parsed that MAKEFLAGS is limited in
this way.  I examined the code and this appears to have always been the case,
so it's not a recent regression.  And I examined the GNU make manual and I can
see no discussion of this behavior so it doesn't seem to be a documented
"feature".

I think this is a bug and that MAKEFLAGS when examined within the makefile
should be equivalent to what will be used when invoking a sub-make.

Unfortunately it's not a completely trivial problem to solve.  We actually
have to parse the MAKEFLAGS variable multiple times, in case the user's
makefile modifies this value.  If we just do the simple thing and add the
flags into MAKEFLAGS then we end up getting multiple copies of options which
are additive like -I.  So before we can make this change we need to have a way
to clear out the previous information about these values else we'll get
multiple copies of additive flags.

In general the behavior of setting MAKEFLAGS in the makefile is fraught and
complex but it's something people definitely expect to be able to do.

___

Reply to this item at:

  

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