makefile - 迭代并构建每个文件
makefile - iterate and build each file
我有一个目录列表 BUILDS := $(wildcard */)
,每个目录都是一个 Dockerfile。
如何构建每个 docker 文件?显然,这行不通,但我正在寻找类似的东西:
build: $(BUILDS)
$(DOCKERCMD) $@ -t $(DOCKER_REPO_URL):$(subst /,,$^) --force-rm $^
撇开细节不谈,您可能需要以下内容:
生成文件
BUILDS := a b c
define build_it =
$(1):
@echo "Building $$@"
touch $$@
endef
.PHONY: all clean
all: $(BUILDS)
$(foreach build,$(BUILDS),$(eval $(call build_it,$(build))))
clean:
rm -f $(BUILDS)
运行方式如下:
$ make
Building a
touch a
Building b
touch b
Building c
touch c
我有一个目录列表 BUILDS := $(wildcard */)
,每个目录都是一个 Dockerfile。
如何构建每个 docker 文件?显然,这行不通,但我正在寻找类似的东西:
build: $(BUILDS)
$(DOCKERCMD) $@ -t $(DOCKER_REPO_URL):$(subst /,,$^) --force-rm $^
撇开细节不谈,您可能需要以下内容:
生成文件
BUILDS := a b c
define build_it =
$(1):
@echo "Building $$@"
touch $$@
endef
.PHONY: all clean
all: $(BUILDS)
$(foreach build,$(BUILDS),$(eval $(call build_it,$(build))))
clean:
rm -f $(BUILDS)
运行方式如下:
$ make
Building a
touch a
Building b
touch b
Building c
touch c