如何创建迭代制作食谱

How to create iterating make recipes

我的 makefile 中有一串依赖项。我想制作一个食谱来构建每个。 "For each" 显然在 Gnu Make 中不起作用。还有其他选择吗?

DEPENDENCIES = dep1 dep2 dep3 ...

for each DEP in $(DEPENDENCIES)

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

通常您不会在 make 中进行迭代,您指定依赖链并让 make 为您处理它。

DEPENDENCIES = dep1 dep2 dep3

.PHONY: all $(DEPENDENCIES)

all: $(DEPENDENCIES)

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