How Simply Expanded Variable Assignment Matters?

I couldn’t understand how Simply Expanded Variable Assignment is different from Recursively Expanded Variable Assignment. And get three questions on the following code –

  1. Why make echo_RT_LIM shows RT_LIM updated value, but SUB_R doesn’t?
  2. If SUB_R uses Simply Expanded Variable Assignment:=, is there a way to allow user reassign the value and reflect in the early defined target – runsim.
  3. According gnu make manual, a disadvantage for Recursively Expanded Variable Assignment is for Transforming Text Functions case that makes make run slower, can you elaborate it by giving a simple example?

As following gnu make manual suggestion by using Simply Expanded Variable Assignment, I came across the problem list as item 2. But if using Recursively Expanded Variable Assignment, will it bring any side effect in this case? Will it still allow user to override the RT_LIM afterwards so that SUB_R is configurable by reassign RT_LIM?

RT_LIM ?= 08:00:00
SUB_R := $(RT_LIM)
SUB_L = $(RT_LIM)

echo_%  : ; @echo $* = $($*)

runsim:
    @echo SUB_R: $(SUB_R)
    @echo SUB_L: $(SUB_L)

# reassign to different value afterwards, such as in a different included file
RT_LIM = 09:00:00

Leave a Comment