Deferred->immediate variable reassignment trick.

Kaz Kylheku <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.