help-make
[Top][All Lists]
Advanced

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

Re: MAKECMDGOALS


From: Paul Smith
Subject: Re: MAKECMDGOALS
Date: Mon, 01 Feb 2021 09:17:19 -0500
User-agent: Evolution 3.36.4-0ubuntu1

On Mon, 2021-02-01 at 11:49 +0100, Sébastien Hinderer wrote:
>    'Make' will set the special variable 'MAKECMDGOALS' to the list of
>    goals you specified on the command line.  If no goals were given on
>    the command line, this variable is empty.
> 
> If I define the following Makefile:
> 
> ifeq "$(MAKECMDGOALS)" ""
> 
> make --warn-undefined-variables
> 
> Makefile:1: warning: undefined variable 'MAKECMDGOALS'
> 
> Am I correct that there is a mismatch between make's documented and
> real behaviour?

Hm.  Well, I could use a language lawyer's response and say that "this
variable is empty" is not the same thing as "this variable is set to
the empty value".

The variable _IS_ empty, in the same way that any unset variable is
empty.

If you want to tell the difference between a variable that is not set
at all versus set to the empty string, you have to use the
$(origin ...) function.

Instead of your code you could use:

    MAKECMDGOALS ?= default

which will set MAKECMDGOALS IFF it has never been set at all (not even
to the empty string).

Probably this section of the documentation should be updated to be more
clear so that reading it doesn't require language lawyering.




reply via email to

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