Cancelling command line arguments for the whole of project

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Cancelling command line arguments for the whole of project

Masahiro Yamada-2
Hi.


Is there an elegant way to cancel
a command line argument?


https://www.gnu.org/software/make/manual/make.html#Override-Directive

explains how to override command arguments,
but it works only in the current Makefile.


The command line argument is still
propagated down to sub-makes when
a user runs "make FOO=xxx"


So, to cancel it for all over the project,
I end up with not only "override FOO="
but also "FOO=" everywhere.

It is ugly when the top Makefile
has a lot of submake call-sites.

------------->---------------

# This cancels FOO only in this Makefile
override FOO=


# We need more efforts to cancel FOO in sub-makes...
sub-make1:
        $(MAKE) FOO=  -C sub1

sub-make2:
        $(MAKE) FOO=   -C sub2

sub-make3:
         $(MAKE) FOO=   -C sub3

 ...

------------->8-------------------



In my understanding, there is no one-liner
solution to cancel it, but it is better to
ask in case I am missing something...


--
Best Regards
Masahiro Yamada

Reply | Threaded
Open this post in threaded view
|

Re: Cancelling command line arguments for the whole of project

Paul Smith-20
On Thu, 2020-05-21 at 16:36 +0900, Masahiro Yamada wrote:
> Is there an elegant way to cancel
> a command line argument?
>
> https://www.gnu.org/software/make/manual/make.html#Override-Directive
>
> explains how to override command arguments,
> but it works only in the current Makefile.

The handling of passing content down to recursive make is discussed in
this section of the manual:

https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html

Here you will discover that overridden variables are contained in the
make variable MAKEOVERRIDES.

Since later settings of variables take precedence over earlier
settings, if you want to change them you simply need to add the new
setting like so:

  # This cancels FOO only in this Makefile
  override FOO=
  # This resets FOO for recursive invocations
  MAKEOVERRIDES += FOO=$(FOO)



Reply | Threaded
Open this post in threaded view
|

Re: Cancelling command line arguments for the whole of project

Masahiro Yamada-2
On Thu, May 21, 2020 at 9:33 PM Paul Smith <[hidden email]> wrote:

>
> On Thu, 2020-05-21 at 16:36 +0900, Masahiro Yamada wrote:
> > Is there an elegant way to cancel
> > a command line argument?
> >
> > https://www.gnu.org/software/make/manual/make.html#Override-Directive
> >
> > explains how to override command arguments,
> > but it works only in the current Makefile.
>
> The handling of passing content down to recursive make is discussed in
> this section of the manual:
>
> https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html
>
> Here you will discover that overridden variables are contained in the
> make variable MAKEOVERRIDES.
>
> Since later settings of variables take precedence over earlier
> settings, if you want to change them you simply need to add the new
> setting like so:
>
>   # This cancels FOO only in this Makefile
>   override FOO=
>   # This resets FOO for recursive invocations
>   MAKEOVERRIDES += FOO=$(FOO)


Awesome!
I did not know this tip.


Thank you!


--
Best Regards
Masahiro Yamada