1CLI_DIR:=$(CURDIR)/components/cli
2ENGINE_DIR:=$(CURDIR)/components/engine
3PACKAGING_DIR:=$(CURDIR)/components/packaging
4MOBY_COMPONENTS_SHA=ab7c118272b02d8672dc0255561d0c4015979780
5MOBY_COMPONENTS_URL=https://raw.githubusercontent.com/docker/moby-extras/$(MOBY_COMPONENTS_SHA)/cmd/moby-components
6MOBY_COMPONENTS=.helpers/moby-components-$(MOBY_COMPONENTS_SHA)
7VERSION=$(shell cat VERSION)
8
9.PHONY: help
10help: ## show make targets
11	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m  %s\n", $$1, $$2}' $(MAKEFILE_LIST)
12
13.PHONY: test-integration-cli
14test-integration-cli: $(CLI_DIR)/build/docker ## test integration of cli and engine
15	$(MAKE) -C $(ENGINE_DIR) DOCKER_CLI_PATH=$< test-integration-cli
16
17$(CLI_DIR)/build/docker:
18	$(MAKE) -C $(CLI_DIR) -f docker.Makefile build
19
20.PHONY: deb
21deb: ## build deb packages
22	$(MAKE) VERSION=$(VERSION) CLI_DIR=$(CLI_DIR) ENGINE_DIR=$(ENGINE_DIR) -C $(PACKAGING_DIR) deb
23
24.PHONY: rpm
25rpm: ## build rpm packages
26	$(MAKE) VERSION=$(VERSION) CLI_DIR=$(CLI_DIR) ENGINE_DIR=$(ENGINE_DIR) -C $(PACKAGING_DIR) rpm
27
28.PHONY: static
29static: ## build static packages
30	$(MAKE) VERSION=$(VERSION) CLI_DIR=$(CLI_DIR) ENGINE_DIR=$(ENGINE_DIR) -C $(PACKAGING_DIR) static
31
32.PHONY: clean
33clean: ## clean the build artifacts
34	-$(MAKE) -C $(CLI_DIR) clean
35	-$(MAKE) -C $(ENGINE_DIR) clean
36	-$(MAKE) -C $(PACKAGING_DIR) clean
37
38$(MOBY_COMPONENTS):
39	mkdir -p .helpers
40	curl -fsSL $(MOBY_COMPONENTS_URL) > $(MOBY_COMPONENTS)
41	chmod +x $(MOBY_COMPONENTS)
42
43.PHONY: update-components
44update-components: update-components-cli update-components-engine update-components-packaging ## udpate components using moby extra tool
45
46.PHONY: update-components-cli
47update-components-cli: $(MOBY_COMPONENTS)
48	$(MOBY_COMPONENTS) update cli
49
50.PHONY: update-components-engine
51update-components-engine: $(MOBY_COMPONENTS)
52	$(MOBY_COMPONENTS) update engine
53
54.PHONY: update-components-packaging
55update-components-packaging: $(MOBY_COMPONENTS)
56	$(MOBY_COMPONENTS) update packaging
57