bug-make
[Top][All Lists]
Advanced

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

Re: Target-specific variable in subdirectory problem


From: Benjamin Cama
Subject: Re: Target-specific variable in subdirectory problem
Date: Thu, 03 Aug 2017 15:39:04 +0200

Le jeudi 03 août 2017 à 09:20 -0400, Kyle Rose a écrit :
> On Aug 3, 2017 9:00 AM, "Benjamin Cama" <address@hidden> wrote:
>         Anyway, it seems that a global variable would solve my problem, and
>         indeed it looks a bit more right this way: I can still get the stem in
>         my recipe (with $*), and everything works as expected. It's just that
>         the global namespace is “polluted” by this variable which is used only
>         in my particular recipe. And this is where I may be mistaken on the 
> use
>         of target-specific variable: I tend to use them as a kind of “private
>         namespace” feature, when I define something that will be used only in
>         one particular recipe.
> 
> 
> What we do in our makefiles is to use global variable names containing
> paths. E.g.,
> 
> 
> subdir/FOO = bar

Thanks for the tip, this looks very useful. Even if in my case, the
subdir is dynamic, but I can prefix the variables with some name
specific to my recipe.

> You can modularize this via some construction like:
> 
> 
> M := subdir
> ...
> $M/FOO = bar

Nice. I see this is also used in OpenWrt, which is my reference for
advanced Makefile usage.

> Make doesn't provide a lot of structure for encapsulation (there are
> no objects or directly-addressable structures, for instance), but it
> does give you enough flexibility to create something manageable.

Yes, and I like that it just gives enough, but is not plagued by
feature-creep.

Thanks.
-- 
Benjamin Cama - Tél : 258




reply via email to

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