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.