bugmake - Bugs: bug #45211, MAKEFLAGS is not parsed until...


bug #45211: MAKEFLAGS is not parsed until after makefiles are read on

Submitted by:  None
Submitted on:  Fri 29 May 2015 10:51:16 AM UTC  
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  None Operating System:  None
Fixed Release:  None Triage Status:  None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sat 30 May 2015 05:12:42 PM UTC, comment #2:

The ?= assignment only sets variables if they are not already set.

The RM variable is set by default.

Resetting the state of make doesn't happen every time MAKEFLAGS is modified. It only happens once, after all makefiles are read in.

So, when the RM ?= rm assignment is seen the RM variable still has its default value, and it is not assigned. Then after all makefiles are read in, MAKEFLAGS is processed and the default assignment for RM is removed, leaving it empty.

I'll mark this as an enhancement request, to consider having changes to MAKEFLAGS take effect immediately instead of after all makefiles are parsed, but this seems like a low priority issue to me.

Why don't you use just "RM = rm" instead of "RM ?= rm", and then things would work the way you want?

Paul D. Smith <psmith>
Project Administrator
Fri 29 May 2015 11:32:42 PM UTC, comment #1:

The claim being, I presume, that the second RM='' should either be RM='rm -f' or RM='rm', the latter only being the case if changing MAKEFLAGS takes effect implausibly quickly. It's the former with a Debian Wheezy make 3.81 (origin says "default"), but empty (origin says "undefined"), per the OP, with git's 4.1.90. As you'd hope, a more normal operation is fine: it's the latter when running make -R aka --no-builtin-variables, with either version.

Martin Dorey <mdorey>
Fri 29 May 2015 10:51:16 AM UTC, original submission:


# Start of Makefile

$(info RM='$(RM)')

RM ?= rm

define make_obj
$(info RM='$(RM)')

$(call make_obj)
# End of Makefile

make output:
RM='rm -f'
make: 'ttt' is up to date.



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

Attach Files:

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 mdorey (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-05-30 psmith Item GroupNone => Enhancement
        SummaryAdd option to MAKEFLAGS (How to set RM variable?) => MAKEFLAGS is not parsed until after makefiles are read on

    Back to the top

    Powered by Savane 3.3