On Sat, 2024-01-27 at 15:52 -0500, rsbec...@nexbridge.com wrote: > > I'm interested in peoples' opinions about which of these two > > implementations they would feel to be more "intuitive" or > > "correct". Also please consider issues of "action at a distance" > > where a variable is assigned in one makefile and appended to in > > some other makefile, potentially far away. > > Intuitive reading of this would seem that "bar=2 2 3" is better, as > +:= should force complete resolution of the string applied to bar, > not partial resolution of foo keeping an instance of $(foo) for > resolution later.
Hm, maybe I'm just weird. Or maybe I chose a poor example. What if the example was like this: foo_ARGS = -a bar_ARGS = -b ARGS = $($@_ARGS) -x all: foo bar foo bar: ; cmd $(ARGS) $@ ARGS +:= $(shell gen-args) where the "gen-args" program outputs "-z". and now the value of ARGS would either be "$($@_ARGS) -x -z" using the method I was suggesting, or it would be " -x -z" using the alternative method where ARGS was converted into a simple variable. So using the first method make would run: cmd -a -x -z foo cmd -b -x -z bar and using the alternative method make would run: cmd -x -z foo cmd -x -z bar Is it still more intuitive? Maybe the answer is "well, just don't do that" :). Or maybe "+!=" could be used in this specific situation, but you get the idea. The problem is that when you write the assignment +:= it's not always so simple to know what the side-effects might be because you don't know what the current behavior of the variable is, and it might change in the future. Of course, that's always a problem with makefiles. -- Paul D. Smith <psm...@gnu.org> Find some GNU make tips at: https://www.gnu.org http://make.mad-scientist.net "Please remain calm...I may be mad, but I am a professional." --Mad Scientist