automake-ng
[Top][All Lists]
Advanced

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

Re: [Automake-NG] [PATCH] [ng] utils: new function 'am.vars.is-undef'


From: Jim Meyering
Subject: Re: [Automake-NG] [PATCH] [ng] utils: new function 'am.vars.is-undef'
Date: Sat, 28 Jul 2012 09:32:14 +0200

Stefano Lattarini wrote:
> Sometimes, in our makefiles, we want to assign a default value to a
> variable that might not have been assigned yet.  One might think that
> using the GNU make assignment '?=' is enough:
>
>     VAR ?= DEFAULT-VALUE
>
> But alas, such an usage allow environment overrides; i.e., if an

s/an /
s/allow/allows/

> environment variable named 'VAR' is present there and defined to,

s/is present there /

> say, BAD-VALUE, the construct above will result in the $(VAR) make
> variable being defined to BAD-VALUE, not to DEFAULT-VALUE.
>
> To help overcoming this situation, we define a new make function

At first I was going to say s/ing//, but how about rewording?

    Use the 'am.vars.is-undef' function to avoid this situation.
    It tells whether the given make variable is ...

> 'am.vars.is-undef', that tells whether the given make variable is
> not "safely" defined, i.e., either undefined, or defined to a value
> that is inherited from the environment.
>
> With such a tool, we can safely declare default values for variables
> that avoids environmental interferences, as follow:
>
>     ifeq ($(call am.vars.is-undef,VAR),yes)
>       VAR = DEFAULT-VALUE
>     endif
>
> * lib/am/header-vars.am (am.vars.is-undef): New.
> * t/internals.tap: Test it, and add few sanity checks.



reply via email to

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