@mkdir -p $@
#
-# Wire build + phony + clean + lifecycle for every (image, type)
-# combo. Profiling FROMs the crossbuild image of the same distro,
-# so its build depends on the corresponding crossbuild stamp.
-#
-$(foreach IMG,$(IMAGES),\
- $(eval $(call DOCKER_BUILD,$(IMG),service,,)) \
- $(eval $(call DOCKER_BUILD,$(IMG),ci,,)) \
- $(eval $(call DOCKER_BUILD,$(IMG),crossbuild,$(if $(CB_FROM_$(IMG)),--build-arg=from=$(CB_FROM_$(IMG))),)) \
- $(eval $(call DOCKER_BUILD,$(IMG),profiling,--build-arg=from=$(DOCKER_IMAGE_PREFIX)-crossbuild/$(IMG):$(GIT_SHA),$(DOCKER_STATE)/stamp-image.$(IMG).crossbuild)) \
- $(foreach T,service ci crossbuild profiling, \
+# Build types, and the per-type knobs DOCKER_BUILD needs. Anything
+# type-specific (extra --build-arg, extra stamp deps) lives here so
+# the per-(image,type) wiring stays a plain double foreach.
+#
+# $(IMG) in these values is resolved at $(eval) time inside the
+# foreach below, so each image sees its own substituted form.
+#
+DOCKER_TYPES := ci crossbuild profiling service
+
+DOCKER_BUILD_ARGS_service :=
+DOCKER_BUILD_ARGS_ci :=
+DOCKER_BUILD_ARGS_crossbuild = $(if $(CB_FROM_$(IMG)),--build-arg=from=$(CB_FROM_$(IMG)))
+DOCKER_BUILD_ARGS_profiling = --build-arg=from=$(DOCKER_IMAGE_PREFIX)-crossbuild/$(IMG):$(GIT_SHA)
+
+DOCKER_BUILD_DEPS_service :=
+DOCKER_BUILD_DEPS_ci :=
+DOCKER_BUILD_DEPS_crossbuild :=
+DOCKER_BUILD_DEPS_profiling = $(DOCKER_STATE)/stamp-image.$(IMG).crossbuild
+
+#
+# Wire build + phony + clean + lifecycle + test for every (image,
+# type) combo. Profiling FROMs the crossbuild image of the same
+# distro, so its build depends on the corresponding crossbuild
+# stamp (see DOCKER_BUILD_DEPS_profiling above).
+#
+$(foreach IMG,$(IMAGES), \
+ $(foreach T,$(DOCKER_TYPES), \
+ $(eval $(call DOCKER_BUILD,$(IMG),$(T),$(DOCKER_BUILD_ARGS_$(T)),$(DOCKER_BUILD_DEPS_$(T)))) \
$(eval $(call DOCKER_PHONY,$(IMG),$(T))) \
$(eval $(call DOCKER_CLEAN,$(IMG),$(T))) \
$(eval $(call DOCKER_LIFECYCLE,$(IMG),$(T))) \
docker.${1}.reset: $(foreach IMG,${2},docker.${1}.$(IMG).reset)
endef
-$(eval $(call DOCKER_TYPE_UMBRELLAS,service,$(IMAGES)))
-$(eval $(call DOCKER_TYPE_UMBRELLAS,ci,$(IMAGES)))
-$(eval $(call DOCKER_TYPE_UMBRELLAS,crossbuild,$(IMAGES)))
-$(eval $(call DOCKER_TYPE_UMBRELLAS,profiling,$(IMAGES)))
+$(foreach T,$(DOCKER_TYPES),$(eval $(call DOCKER_TYPE_UMBRELLAS,$(T),$(IMAGES))))
#
# Across-type umbrellas. 'docker' stays as a legacy alias for the
.PHONY: docker docker.common docker.clean docker.up docker.down docker.reset docker.info docker.info_header
docker: docker.info docker.service
docker.common: docker.info $(foreach IMG,$(DOCKER_COMMON),docker.service.$(IMG))
-docker.clean: docker.ci.clean docker.crossbuild.clean docker.profiling.clean docker.service.clean
-docker.up: docker.ci.up docker.crossbuild.up docker.profiling.up docker.service.up
-docker.down: docker.ci.down docker.crossbuild.down docker.profiling.down docker.service.down
-docker.reset: docker.ci.reset docker.crossbuild.reset docker.profiling.reset docker.service.reset
+
+define DOCKER_VERB_UMBRELLA
+docker.${1}: $(foreach T,$(DOCKER_TYPES),docker.$(T).${1})
+endef
+
+$(foreach V,clean up down reset,$(eval $(call DOCKER_VERB_UMBRELLA,$(V))))
docker.info: docker.info_header $(foreach IMG,$(IMAGES),docker.service.$(IMG).status)
@echo All images: $(IMAGES)
endef
#
-# Wire each (image, type) Dockerfile rule plus the per-type regen
-# and drift-check umbrellas. Profiling is filtered to PROFILING_IMAGES
-# because it doesn't have an rpm template.
+# Build types. Per-type m4 prereqs follow the <type>.deb.m4 /
+# <type>.rpm.m4 naming convention so DOCKERFILE_RULE picks them up
+# from $(T) alone.
#
-$(foreach IMG,$(IMAGES),\
- $(eval $(call DOCKERFILE_RULE,$(IMG),service,$(CB_DIR)/m4/service.deb.m4 $(CB_DIR)/m4/service.rpm.m4)) \
- $(eval $(call DOCKERFILE_RULE,$(IMG),ci,$(CB_DIR)/m4/ci.deb.m4 $(CB_DIR)/m4/ci.rpm.m4)) \
- $(eval $(call DOCKERFILE_RULE,$(IMG),crossbuild,$(CB_DIR)/m4/crossbuild.deb.m4 $(CB_DIR)/m4/crossbuild.rpm.m4)) \
- $(eval $(call DOCKERFILE_RULE,$(IMG),profiling,$(CB_DIR)/m4/profiling.deb.m4 $(CB_DIR)/m4/profiling.rpm.m4)))
+DOCKERFILE_TYPES := ci crossbuild profiling service
-$(eval $(call DOCKERFILE_ALL,dockerfile.service,service,$(IMAGES)))
-$(eval $(call DOCKERFILE_ALL,dockerfile.ci,ci,$(IMAGES)))
-$(eval $(call DOCKERFILE_ALL,dockerfile.crossbuild,crossbuild,$(IMAGES)))
-$(eval $(call DOCKERFILE_ALL,dockerfile.profiling,profiling,$(IMAGES)))
+#
+# Wire each (image, type) Dockerfile rule plus the per-type regen
+# and drift-check umbrellas.
+#
+$(foreach IMG,$(IMAGES), \
+ $(foreach T,$(DOCKERFILE_TYPES), \
+ $(eval $(call DOCKERFILE_RULE,$(IMG),$(T),$(CB_DIR)/m4/$(T).deb.m4 $(CB_DIR)/m4/$(T).rpm.m4))))
-$(eval $(call DOCKERFILE_CHECK,dockerfile.service.check,service,$(IMAGES),dockerfile.service))
-$(eval $(call DOCKERFILE_CHECK,dockerfile.ci.check,ci,$(IMAGES),dockerfile.ci))
-$(eval $(call DOCKERFILE_CHECK,dockerfile.crossbuild.check,crossbuild,$(IMAGES),dockerfile.crossbuild))
-$(eval $(call DOCKERFILE_CHECK,dockerfile.profiling.check,profiling,$(IMAGES),dockerfile.profiling))
+$(foreach T,$(DOCKERFILE_TYPES), \
+ $(eval $(call DOCKERFILE_ALL,dockerfile.$(T),$(T),$(IMAGES))) \
+ $(eval $(call DOCKERFILE_CHECK,dockerfile.$(T).check,$(T),$(IMAGES),dockerfile.$(T))))
.PHONY: dockerfile dockerfile.check
-dockerfile: dockerfile.ci dockerfile.crossbuild dockerfile.profiling dockerfile.service
-dockerfile.check: dockerfile.ci.check dockerfile.crossbuild.check dockerfile.profiling.check dockerfile.service.check
+dockerfile: $(foreach T,$(DOCKERFILE_TYPES),dockerfile.$(T))
+dockerfile.check: $(foreach T,$(DOCKERFILE_TYPES),dockerfile.$(T).check)
#
# Glossary of type identifiers, shared by docker.help / dockerfile.help.