On Fri, 2009-04-03 at 23:38 -0400, Michael R. Head wrote:
> I'd like to make a rule that generates a output file for each pair in
> the cross product of two lists of input files. I have a simple makefile
> that does what I want, but it's ugly. 
> 
> I'm wondering if anyone has any suggestions on improving it. At a
> minimum, I'd like to get rid of the foreachs in the targets.

Here's one tiny improvement:

As=a1 a2 a3
Bs=b4 b5 b6
ABs=$(foreach a,$(As),$(foreach b,$(Bs),$(a)_$(b)))
A=$(filter-out $@,$(foreach b,$(Bs),$(subst _$(b),,$@)))
B=$(filter-out $@,$(foreach a,$(As),$(subst $(a)_,,$@)))
A_SE=$$(filter-out $$@,$$(foreach b,$$(Bs),$$(subst _$$(b),,$$@)))
B_SE=$$(filter-out $$@,$$(foreach a,$$(As),$$(subst $$(a)_,,$$@)))

all: $(ABs)

$(As) $(Bs):

.SECONDEXPANSION:

$(ABs): $(A_SE) $(B_SE)
        @echo $@: $^
        @echo A=$A, B=$B


-- 
Michael R. Head <[email protected]>
http://www.suppressingfire.org/~burner/
http://suppressingfire.livejournal.com


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to