help-make
[Top][All Lists]
Advanced

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

Re: buggy interaction between MAKEFLAGS += rR and CC ?= my_gcc


From: Paul Smith
Subject: Re: buggy interaction between MAKEFLAGS += rR and CC ?= my_gcc
Date: Fri, 26 Aug 2016 11:37:58 -0400

Please be sure to keep the mailing list in the loop, thanks!

On Thu, 2016-08-25 at 11:55 -0800, Britton Kerin wrote:
> It should explicitly mention that setting it in a makefile won't set
> flags for that instance.

It does set them for that instance, just not until after all the
makefiles have been parsed.  So the new flags take effect after the
makefiles have been parsed and before make starts trying to build
targets.

As far as I know it should be possible to do any combination of things
that you want with the current behavior.  It will be more ugly than
using a simple ?= (for example) but it will be less ugly than testing
for command line flags and failing if they're not provided.

For example this:

  MAKEFLAGS += -rR

  CC ?= my_gcc

says, as far as I can tell, "use the user's version of CC from either
the command line or the environment, or if that's not set then use
my_gcc", which can be written like this:

  # In case you wanted it for other reasons...
  MAKEFLAGS += -rR

  ifneq (,$(filter default undefined,$(origin CC)))
  CC = my_gcc
  endif

You can turn this into a macro and use call or eval if you have a lot
of these.



reply via email to

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