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, 08 Jul 2014 14:14:33 +0200

Hi,

Le vendredi 04 juillet 2014 à 12:36 -0700, Philip Guenther a écrit :
> This combination of behaviors is caused by the requirement that
> variables 
> set on the make command-line are exported to the environment for
> commands 
> by default.
> 
> For a normal recursively expanded variable, the value placed in the 
> environment has to be expanded completely before being placed in the 
> environment.  That expansion happens at the last moment, after the 
> commands are expanded but before the shell is invoked.  That explains
> the 
> original example.
> 

Thanks for the answer. I understand the way it works now.

> 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)

And the examples:

  $ ./make -f ./info.mk RECIPE=': $(info 2)'
  1
  2
  3

  $ RECIPE=': $(info 2)' ./make -f ./info.mk
  1
  2
  3

Regards.

-- 
Yann Droneaud
OPTEYA





reply via email to

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