bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #26596] MAKEFLAGS documentation tweak


From: Paul Smith
Subject: Re: [bug #26596] MAKEFLAGS documentation tweak
Date: Wed, 22 May 2013 12:56:26 -0400

On Wed, 2013-05-22 at 17:42 +0200, Stefano Lattarini wrote:
> Hi Paul.
> 
> On 05/22/2013 05:17 PM, Paul D. Smith wrote:
> > Follow-up Comment #1, bug #26596 (project make):
> > 
> > Hm.  I'm not sure why the immediate expansion has limited content.  Is there
> > any purpose to this?  Wouldn't it just be better to have the immediate
> > expansion resolve to the entire thing?  I'll have to look into it; maybe
> > there's a good reason for doing it this way.
> >
> FWIW, the current behavior of $(MFLAGS) and $(MAKEFLAGS) is used as a
> feature in Automake-NG (my Automake fork that assumes the generated
> makefiles will only be run by GNU make); see the comments about the
> 'am.make.is-running-with-option' macro in
> <http://git.sv.gnu.org/cgit/automake.git/tree/lib/am/header-vars.mk?h=ng/master>
> Changing it will probably break something there :-(

Perhaps... I'm not sure.

> But maybe, are you willing to implement new macro(s) that makes is
> easier to probe at runtime, from within the makefiles, the flags
> passed to GNU make?  In that case, I'd be more than willing to adjust
> Automake and/or Automake-NG to take advantage of that.

I've reworked the MFLAGS / MAKEFLAGS generation to be more regular and
rigorous yesterday, for 4.0, and to preserve _some_ backward-compat; I
had thought about this issue when I did so.  Please comment on the
rules:

For MAKEFLAGS:
     1. In all cases where an option has both single-letter and long
        formats, the single-letter format will be used regardless of
        what appeared on the command line.
     2. If there are no options or variable assignments for MAKEFLAGS,
        it will resolve to the empty string.
     3. Any single-letter / no argument options will always be in the
        first word; there will be no "-" prefix to this word
     4. If there are no single-letter / no argument options, the first
        character in MAKEFLAGS will be a space.
     5. Next, any options that have single-letter variations but take
        arguments (optional or not) will appear, as " -X[arg]" (these
        can never be combined).
     6. Next any options that have only long names, with or without
        arguments, will appear, as " --OPTION[=arg]".
     7. Next, any --eval options appear.
     8. Finally if there are any variable assignments, " -- " will be
        added followed by the variable assignments
     9. All arguments above are quoted as needed by GNU make to parse
        them from the environment

For MFLAGS:
     1. Rules 1-3,5,6 above hold, except that if there are
        single-letter/no argument options they will always be preceded
        by a "-".
     2. If there are no single-letter / no argument options, the whole
        section is not present (i.e., no leading single dash, no leading
        space, etc.)

For some reason, --eval options are not added to MFLAGS.  That might be
a bug.

As a result, it should be completely reliable to use something like this
to test for single-character, no argument options:

  $(if $(findstring k,$(firstword -$(MAKEFLAGS))),found k,no k)

Similarly you can test for single-character, argument options like this:

  $(if $(filter -I%,$(MAKEFLAGS)),found -I, no -I)

And long options like this:

  $(if $(filter --trace%,$(MAKEFLAGS)),found --trace,no --trace)

I understand that from a backward-compatibility standpoint relying on
this behavior is problematic.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]