help-make
[Top][All Lists]
Advanced

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

Re: $(info ...) in variable, with expansion in recipes


From: Yann Droneaud
Subject: Re: $(info ...) in variable, with expansion in recipes
Date: Tue, 15 Jul 2014 17:19:34 +0200

Hi,

Le mardi 08 juillet 2014 à 09:27 -0700, Philip Guenther a écrit :
> On Tue, Jul 8, 2014 at 5:14 AM, Yann Droneaud <address@hidden>
> wrote:
>         Le vendredi 04 juillet 2014 à 12:36 -0700, Philip Guenther a
>         écrit :
> ... 
>         > This can be confirmed by tell make that the RECIPE variable
>         doesn't
>         > need
>         > to be exported.  If you add this line to the Makefile:
>         >     unexport RECIPE
>         >
>         > then the second '2' output goes away.
>         
>         
>         Thanks again, this is the perfect work around I was hoping
>         for.
>         
>         Here's the new makefile fragment:
>         
>           ifeq ($(V),1)
>           Q :=
>           else
>           Q ?= @
>           endif
>         
>           all:
>                 $(Q) : $(info 1)
>         
>                 $(Q)$(eval unexport RECIPE)$(RECIPE)
>                 $(Q) : $(info 3)
> 
> 
> I give up: why do you feel the need to do the unexport via an $(eval)
> in the recipe?  What problem are you trying to solve?
> 

I understand your disappointment.

I have noticed the variables from the environment are expanded once
before excuting the first line of the recipe (I've thought previously
it would be done for each line). So this seems to work.

Now, I've used $(eval unexport) in a very complicated onliner which
first check for the variable to be defined, and if not, report an error.

In this case, 'unexporting' the variable at toplevel will make it 
defined so my check will never catch on undefined variable.

Note that the check on the variable must only be done if the specific 
target (here all:) is to be rebuilt.

This end up having $(eval unexport RECIPE) in the recipe instead of
toplevel.

Now have a look at one of my best nightmare (aka. the beast):

exec:
        $(Q)$(if $(findstring undefined,$(origin EXEC)),\
              $(error EXEC= must be used to specify the command to execute),\
              $(if $(filter-out expand,$(EXEC_OPTIONS)),\
                $(error EXEC_OPTIONS= support only 'expand' keyword),\
                $(eval unexport EXEC)$(if $(findstring expand,$(EXEC_OPTIONS)),
\
                                            $(EXEC),\
                                            $(value EXEC))))

> 
> (I am clever enough to know that I am not clever enough to use
> $(eval).)
> 
> 

I'm not so wise ...

Regards.

-- 
Yann Droneaud
OPTEYA






reply via email to

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