help-make
[Top][All Lists]
Advanced

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

Deferred->immediate variable reassignment trick.


From: Kaz Kylheku
Subject: Deferred->immediate variable reassignment trick.
Date: Tue, 20 Jun 2023 11:46:45 -0700
User-agent: Roundcube Webmail/1.4.13

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.



reply via email to

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