On Wed, Mar 3, 2021 at 1:00 PM Goran V. <sendmailtogo...@gmail.com> wrote:
> Am Mittwoch, den 03.03.2021, 15:41 -0500 schrieb Paul Smith: > > If by "a feature like that" you mean a way to create multiple pattern > > rules with a single rule definition in the makefile, then obviously > > this would require some new syntax but assuming that syntax existed I > > don't see why it would break anything. > > Yes, that is what I mean with "a feature like that". But I must say > that I'm in no position to propose a patch as make is huge, > http://git.savannah.gnu.org/cgit/make.git/tree/ . > This can be emulated in current GNU make via a function and a variable to hold the commands. To get the effect you wanted, you would define this function in one place, before any use of it: independent_patterns = $(foreach target, $1, $(eval ${target}: ${2}; $(value $(strip $3)))) Then, instead of writing what you tried: $(BUILD)/$(FRONTEND)/%.html \ $(BUILD)/$(FRONTEND)/%.js \ $(BUILD)/$(FRONTEND)/%.css \ $(BUILD)/$(FRONTEND)/%.svg \ $(BUILD)/$(FRONTEND)/%.ico: @echo -n "$(FRONTEND) - building $@" @$(MD) $(BUILD)/$(FRONTEND) @cp $(FRONTEND)/$(@F) $@ @echo " ...done" You would write this: define cmds @echo -n "$(FRONTEND) - building $@" @$(MD) $(BUILD)/$(FRONTEND) @cp $(FRONTEND)/$(@F) $@ @echo " ...done" endef $(call independent_patterns, \ $(BUILD)/$(FRONTEND)/%.html \ $(BUILD)/$(FRONTEND)/%.js \ $(BUILD)/$(FRONTEND)/%.css \ $(BUILD)/$(FRONTEND)/%.svg \ $(BUILD)/$(FRONTEND)/%.ico, , cmds) Not the most obvious, friendly syntax, but it appears to do what you're trying to accomplish. Philip Guenther