Stewart
Stewart

Reputation: 5012

How to create iterating make recipes

I have a string of dependencies in my makefile. I'd like to make a recipe to build each one. The "For each" obviously doesn't work in Gnu Make. Is there another option to achieve this?

DEPENDENCIES = dep1 dep2 dep3 ...

for each DEP in $(DEPENDENCIES)

$(DEP) : 
    $(MAKE) -C ext/$@

Upvotes: 1

Views: 86

Answers (1)

user657267
user657267

Reputation: 21000

Generally you don't iterate in make, you specify the dependency chain and let make handle it for you.

DEPENDENCIES = dep1 dep2 dep3

.PHONY: all $(DEPENDENCIES)

all: $(DEPENDENCIES)

$(DEPENDENCIES): 
    $(MAKE) -C ext/$@

Upvotes: 1

Related Questions