bugmake - Bugs: bug #58341, MAKEFLAGS in the makefile contains...

 
 

bug #58341: MAKEFLAGS in the makefile contains only simple options

Submitter:  Roy Ivy <rivy>
Submitted:  Sat 09 May 2020 06:22:15 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.2.1 Operating System:  Any
Fixed Release:  4.4 Triage Status:  Medium Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 06 Sep 2021 03:08:40 AM UTC, comment #2: 

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

Paul D. Smith <psmith>
Group administrator
Sun 18 Apr 2021 08:46:14 PM UTC, 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.

Paul D. Smith <psmith>
Group administrator
Sat 09 May 2020 06:22:15 PM UTC, original submission:  

OS=Windows_NT (Win10)
MAKE_VERSION=4.2.1

When executing make in a specific debug mode using the `--debug[=FLAGS]` option and tested in the Makefile, ${MAKEFILE} does not have the 'd' flag within it. Oddly, when printing the database with `-p` (or `--print-data-base`), the "# Variables" section contains:

```
# makefile
MAKEFLAGS = p --debug=b -- $(MAKEOVERRIDES)
```

During the same execution, `$(info MAKEFLAGS=${MAKEFLAGS})` prints "MAKEFLAGS=p" (no d).

When executed with `-d` at the command line, the "d" is included in the normally accessible MAKEFLAGS variable.

Is this the expected behavior?
How can I access the "MAKEFLAGS" value printed in the database?

Thanks for your attention.

Roy Ivy <rivy>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by rivy (Submitted the item)
  • -email is unavailable- added by rivy
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-09-06 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Operating SystemNone Any
        Fixed ReleaseNone 4.4
        Triage StatusNone Medium Effort
    2021-04-18 psmith Summary`make --debug` does not set 'd' in MAKEFLAGS MAKEFLAGS in the makefile contains only simple options
    2020-05-09 rivy Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code