[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simulating multiple wildcards in a match using .SECONDEXPANSION?

From: Michael R. Head
Subject: Simulating multiple wildcards in a match using .SECONDEXPANSION?
Date: Fri, 03 Apr 2009 23:38:56 -0400

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.

As=a1 a2 a3
Bs=b4 b5 b6
ABs=$(foreach a,$(As),$(foreach b,$(Bs),$(a)_$(b)))

all: $(ABs)

$(As) $(Bs):


$(ABs): A=$(filter-out $@,$(foreach b,$(Bs),$(subst _$(b),,$@)))
$(ABs): B=$(filter-out $@,$(foreach a,$(As),$(subst $(a)_,,$@)))
$(ABs): $$(filter-out $$@,$$(foreach b,$$(Bs),$$(subst _$$(b),,$$@))) \
  $$(filter-out $$@,$$(foreach a,$$(As),$$(subst $$(a)_,,$$@)))
        @echo $@: $^
        @echo A=$A, B=$B

Michael R. Head <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]