Using GNU-make, let's say that I have two lists in my Makefile, and I want to combine them to get their Cartesian product as another list, so that I can use it as a target list.
As an example from another language that I know better, R has an expand.grid () function that can do this.
I really figured out a way to do this using the Makefile:
.PHONY: all prefix := 1 2 base := AB add_prefix = $(addsuffix $(base), $(prefix)) Obj = $(foreach base, $(base), $(add_prefix)) all: @echo $(Obj)
But this is pretty hacky and doesn't use the adduffix function in an intuitive way. Is there a better way to do this?
source share