Thanks a lot and again, Paul, for your response. With some help I managed to make the macro work even when the variables it uses are defined after the call to the macro.
However, I noticed that secondary expansion seem to not play very well with the shorthand syntax for substitution: $$(foo:=.o) didnr't work, whereas $$(patsubst %,%.o, $$foo) works. Is this known / documented? Or did I perhaps miss something and there is a way to make the shorter syntax work? Cheers, Sébastien.