Follow-up Comment #4, bug #44308 (project make): Your example reminded me similar constructions I use a lot in my own Makefiles.
I use a technique which I call the eval/value style which allows me to generate parametric Make code without having to deal with annoying levels of $ quoting. Here's how I would write your example: {{{ code = $(eval $(value code.mk)) define code.mk x_$1 = some value y_$1 = $(x_$1) append value echo-$1: 1 := $1 echo-$1: @echo x = $(x_$1) @echo y = $(y_$1) endef $(call code,foo) $(call code,bar) all: echo-foo echo-bar }}} It then works as you expected. Well, I actually won't recommend the `1 := $1` hack, use rather some expressive name here ;-) A better example: {{{ x_foo = some FOO value x_bar = some BAR value code = $(eval $(value code.mk)) define code.mk y_$1 = $(x_$(param)) append value echo-$1: param := $1 echo-$1: @echo x = $(x_$(param)) @echo y = $(y_$(param)) endef $(call code,foo) $(call code,bar) all: echo-bar }}} Gives: {{{ $ make all x = some FOO value y = some FOO value append value x = some BAR value y = some BAR value append value }}} That being said, you have to be extra careful about where you place your numerical parameters. If you don't want to rely on the fact that your `$(y_$1)` variable gets only used within rules where `$(param)` is defined, then you should use an `:=` assignment (e.g. `y_$1 := $(x_$1) append value`). So having a special kind of variable which would expand only the numerical parameters like Paul suggested would avoid the need to think too hard about what happens when that code is executed, as the parameters would no longer be there at this point. Since these variables would probably only be useful when defining Make code, it wouldn't be a big limitation to reserve them to multiline variable definition, something like: {{{ defmacro code x_$1 = some value y_$1 = $(x_$1) append value echo-$1: @echo x = $(x_$1) @echo y = $(y_$1) endef $(call code,foo) $(call code,bar) all: echo-foo echo-bar }}} _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?44308> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make