help-make
[Top][All Lists]
Advanced

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

Re: Deferred->immediate variable reassignment trick.


From: Paul Smith
Subject: Re: Deferred->immediate variable reassignment trick.
Date: Tue, 20 Jun 2023 15:55:21 -0400
User-agent: Evolution 3.48.3 (by Flathub.org)

On Tue, 2023-06-20 at 11:46 -0700, Kaz Kylheku wrote:
> I used a trick in a makefile along the following pattern. It works
> fine.  I'm just circulating it for any comments/discussion. 
> 
>   # Delayed evaluation on purpose: 
> 
>   IMPORTANT_VAR = $(shell $CODE_TO_CALCULATE_IMPORTANT_VAR) 
> 
>   # Force lazy variable to be eager: 
> 
>   IMPORTANT_VAR := $(IMPORTANT_VAR) 
> 
> The requirements being hit here are: 
> 
> 1. We want the user to be able to override IMPORTANT_VAR from the
> command line. When the user overrides IMPORTANT_VAR, the shell
> command must not be executed. 
> 
> 2. We don't want every substitution of $(IMPORTANT_VAR) to be running
> the shell command.

I don't understand how this is different than just:

    IMPORTANT_VAR := $(IMPORTANT_VAR)

If the user specifies an override of the variable on the command line
then the value in the makefile will never be used, so the shell command
will never be invoked.



reply via email to

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