help-make
[Top][All Lists]
Advanced

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

Re: target-specific variables


From: Der Herr Hofrat
Subject: Re: target-specific variables
Date: Sun, 14 Mar 2004 20:38:22 +0100 (CET)

> >>> I'd still like to use the $(shell ...) stuff and define a variable, 
> >>> but only if the target t1 is executed. Is there any trick to achieve 
> >>> that?
> >>
> >> ohh, i guess = instead of := does the trick, although the 
> >> shell-command will be executed many times if the variable is used many 
> >> times.
> > 
> > It seems clearly documented to me, but here's an example anyway:
> > 
> > [exmaple]
> 
> what about the $(shell ..) stuff i used in my example?
> of course target-specific variables work like in you example, but 
> although not needed,
>    t1: TEST:=$(shell find)
> would cause find to be executed no matter which make-target i run.
> That's the point i want to avoid. I only want the shell-command to be 
> run once and only if a specific make-target is run.
> 
> TEST=$(shell find) is a workaround in my case, since i use $(TEST) only 
> once, but if i would use it multiple times, the shell-command would also 
> be executed multiple times. That's again something, that i don't want. 
> The shell-command should be executed only once.
>

Should be no problem for GNU make.

info make -->
  * Using Variables:: -->
    * Target-specific::

   ...

   Set a target-specific variable value like this:

     TARGET ... : VARIABLE-ASSIGNMENT

or like this:

     TARGET ... : override VARIABLE-ASSIGNMENT

   Multiple TARGET values create a target-specific variable value for
each member of the target list individually.

   The VARIABLE-ASSIGNMENT can be any valid form of assignment;
recursive (`='), static (`:='), appending (`+='), or conditional
(`?=').  All variables that appear within the VARIABLE-ASSIGNMENT are
evaluated within the context of the target: thus, any
previously-defined target-specific variable values will be in effect.
Note that this variable is actually distinct from any "global" value:
the two variables do not have to have the same flavor (recursive vs.
...snip... 

hofrat




reply via email to

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