help-make
[Top][All Lists]
Advanced

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

Re: Detect unset variables in gnu make


From: Eric Melski
Subject: Re: Detect unset variables in gnu make
Date: Wed, 9 Apr 2014 12:52:50 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4

On 04/09/2014 11:40 AM, Rakesh Sharma wrote:
Hello Guenther,

Thanks for the tips about the $(origin varname) function. That is solving the 
problems I was having. As regards the value of the variable I like to keep them 
in 3 domains:

unset <- never been defined (or undefined midway)
null <- defined but set to an empty value (/^$/) => length($var) = 0
nonnull <- defined & set to a nonnull value(even if all spaces /^\s+$/ or /\S/ or 
better still /./)   =>  length($var) > 0

But like you mentioned, I am coming around to the fact that null or unset 
variables need to be clubbed together in make.

I am finding a great dichotomy in the way make handles newlines embedded within 
make variables. $(info ...$(string_with_NLs_)  outputs ok,
but the same string when used inside recipies (i.e., shell) creates untold 
misery. No amount of escaping, subst, etc. seem to help here.

Rakesh,

It can be quite tricky to use variables with embedded newlines in make. If you're using GNU make 4.0, the $(file) function may provide you a solution. Otherwise, this answer on StackOverflow may help:

http://stackoverflow.com/a/649462/77345

Best regards,

Eric Melski
Chief Architect
Electric Cloud, Inc.
http://blog.melski.net





reply via email to

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