help-make
[Top][All Lists]
Advanced

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

Re: Checking that required variables have been set


From: Philip Guenther
Subject: Re: Checking that required variables have been set
Date: Wed, 25 Jun 2008 17:28:52 -0700

On Wed, Jun 25, 2008 at 4:13 PM, Elmar Kurgpold <address@hidden> wrote:
> I get the same output, but now I see the problem. This code will work if the
> var is not in the include file at all, but it will ignore vars that have
> empty strings. So if you added:
>
> SOMETHING_ELSE=
>
> ...then the code below would show no error. I'll have to make sure these
> vars have a value. Almost there..

Ah, that's because I used $(origin) to avoid expanding the variable.
To *exactly* mimic ifndef, use this:

missing = $(foreach var,${required},$(if $(value ${var}),,${var})

Given these:
 empty=
 nothing=${empty}

that'll report 'empty' as missing but *won't* report 'nothing' as
missing, just like the ifndef test would.


If you want to treat both 'empty' and 'nothing' as missing, then use this:

missing = $(foreach var,${required},$(if ${${var}},,${var})

(Note that the $(value) function used by the version at top was added
in GNU make 3.80)


Philip Guenther




reply via email to

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