@@ -39,13 +39,11 @@ GOFILES := $(shell $(GOCMD) run tools$/lister$/main.go)
3939
4040all : test build package
4141
42+ GOOS_ARCHS = linux/amd64 linux/arm64 linux/ppc64le linux/s390x
43+
4244build : build-linux-amd64 build-linux-arm64 build-windows-amd64 build-linux-ppc64le build-linux-s390x
4345
44- build-linux-amd64 : build-linux-amd64-lifecycle build-linux-amd64-symlinks build-linux-amd64-launcher
45- build-linux-arm64 : build-linux-arm64-lifecycle build-linux-arm64-symlinks build-linux-arm64-launcher
4646build-windows-amd64 : build-windows-amd64-lifecycle build-windows-amd64-symlinks build-windows-amd64-launcher
47- build-linux-ppc64le : build-linux-ppc64le-lifecycle build-linux-ppc64le-symlinks build-linux-ppc64le-launcher
48- build-linux-s390x : build-linux-s390x-lifecycle build-linux-s390x-symlinks build-linux-s390x-launcher
4947
5048build-image-linux-amd64 : build-linux-amd64 package-linux-amd64
5149build-image-linux-amd64 : ARCHIVE_PATH=$(BUILD_DIR ) /lifecycle-v$(LIFECYCLE_VERSION ) +linux.x86-64.tgz
@@ -72,153 +70,48 @@ build-image-linux-s390x: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSIO
7270build-image-linux-s390x :
7371 $(GOCMD ) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH ) -os linux -arch s390x -tag lifecycle:$(LIFECYCLE_IMAGE_TAG )
7472
75- build-linux-amd64-lifecycle : $(BUILD_DIR ) /linux-amd64/lifecycle/lifecycle
76-
77- build-linux-arm64-lifecycle : $(BUILD_DIR ) /linux-arm64/lifecycle/lifecycle
78-
79- build-linux-ppc64le-lifecycle : $(BUILD_DIR ) /linux-ppc64le/lifecycle/lifecycle
80-
81- build-linux-s390x-lifecycle : $(BUILD_DIR ) /linux-s390x/lifecycle/lifecycle
82-
83- $(BUILD_DIR ) /linux-amd64/lifecycle/lifecycle : export GOOS:=linux
84- $(BUILD_DIR ) /linux-amd64/lifecycle/lifecycle : export GOARCH:=amd64
85- $(BUILD_DIR ) /linux-amd64/lifecycle/lifecycle : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
86- $(BUILD_DIR ) /linux-amd64/lifecycle/lifecycle : $(GOFILES )
87- $(BUILD_DIR ) /linux-amd64/lifecycle/lifecycle :
88- @echo " > Building lifecycle/lifecycle for $( GOOS) /$( GOARCH) ..."
89- mkdir -p $(OUT_DIR )
90- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /lifecycle -a ./cmd/lifecycle
91-
92- $(BUILD_DIR ) /linux-arm64/lifecycle/lifecycle : export GOOS:=linux
93- $(BUILD_DIR ) /linux-arm64/lifecycle/lifecycle : export GOARCH:=arm64
94- $(BUILD_DIR ) /linux-arm64/lifecycle/lifecycle : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
95- $(BUILD_DIR ) /linux-arm64/lifecycle/lifecycle : $(GOFILES )
96- $(BUILD_DIR ) /linux-arm64/lifecycle/lifecycle :
97- @echo " > Building lifecycle/lifecycle for $( GOOS) /$( GOARCH) ..."
98- mkdir -p $(OUT_DIR )
99- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /lifecycle -a ./cmd/lifecycle
100-
101- $(BUILD_DIR ) /linux-ppc64le/lifecycle/lifecycle : export GOOS:=linux
102- $(BUILD_DIR ) /linux-ppc64le/lifecycle/lifecycle : export GOARCH:=ppc64le
103- $(BUILD_DIR ) /linux-ppc64le/lifecycle/lifecycle : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
104- $(BUILD_DIR ) /linux-ppc64le/lifecycle/lifecycle : $(GOFILES )
105- $(BUILD_DIR ) /linux-ppc64le/lifecycle/lifecycle :
106- @echo " > Building lifecycle/lifecycle for $( GOOS) /$( GOARCH) ..."
107- mkdir -p $(OUT_DIR )
108- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /lifecycle -a ./cmd/lifecycle
109-
110- $(BUILD_DIR ) /linux-s390x/lifecycle/lifecycle : export GOOS:=linux
111- $(BUILD_DIR ) /linux-s390x/lifecycle/lifecycle : export GOARCH:=s390x
112- $(BUILD_DIR ) /linux-s390x/lifecycle/lifecycle : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
113- $(BUILD_DIR ) /linux-s390x/lifecycle/lifecycle : $(GOFILES )
114- $(BUILD_DIR ) /linux-s390x/lifecycle/lifecycle :
115- @echo " > Building lifecycle/lifecycle for $( GOOS) /$( GOARCH) ..."
116- mkdir -p $(OUT_DIR )
117- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /lifecycle -a ./cmd/lifecycle
118-
119- build-linux-amd64-launcher : $(BUILD_DIR ) /linux-amd64/lifecycle/launcher
120-
121- $(BUILD_DIR ) /linux-amd64/lifecycle/launcher : export GOOS:=linux
122- $(BUILD_DIR ) /linux-amd64/lifecycle/launcher : export GOARCH:=amd64
123- $(BUILD_DIR ) /linux-amd64/lifecycle/launcher : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
124- $(BUILD_DIR ) /linux-amd64/lifecycle/launcher : $(GOFILES )
125- $(BUILD_DIR ) /linux-amd64/lifecycle/launcher :
126- @echo " > Building lifecycle/launcher for $( GOOS) /$( GOARCH) ..."
127- mkdir -p $(OUT_DIR )
128- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /launcher -a ./cmd/launcher
129- test $$(du -m $(OUT_DIR ) /launcher|cut -f 1 ) -le 3
130-
131- build-linux-arm64-launcher : $(BUILD_DIR ) /linux-arm64/lifecycle/launcher
132-
133- $(BUILD_DIR ) /linux-arm64/lifecycle/launcher : export GOOS:=linux
134- $(BUILD_DIR ) /linux-arm64/lifecycle/launcher : export GOARCH:=arm64
135- $(BUILD_DIR ) /linux-arm64/lifecycle/launcher : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
136- $(BUILD_DIR ) /linux-arm64/lifecycle/launcher : $(GOFILES )
137- $(BUILD_DIR ) /linux-arm64/lifecycle/launcher :
138- @echo " > Building lifecycle/launcher for $( GOOS) /$( GOARCH) ..."
139- mkdir -p $(OUT_DIR )
140- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /launcher -a ./cmd/launcher
141- test $$(du -m $(OUT_DIR ) /launcher|cut -f 1 ) -le 3
142-
143- build-linux-ppc64le-launcher : $(BUILD_DIR ) /linux-ppc64le/lifecycle/launcher
144-
145- $(BUILD_DIR ) /linux-ppc64le/lifecycle/launcher : export GOOS:=linux
146- $(BUILD_DIR ) /linux-ppc64le/lifecycle/launcher : export GOARCH:=ppc64le
147- $(BUILD_DIR ) /linux-ppc64le/lifecycle/launcher : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
148- $(BUILD_DIR ) /linux-ppc64le/lifecycle/launcher : $(GOFILES )
149- $(BUILD_DIR ) /linux-ppc64le/lifecycle/launcher :
150- @echo " > Building lifecycle/launcher for $( GOOS) /$( GOARCH) ..."
151- mkdir -p $(OUT_DIR )
152- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /launcher -a ./cmd/launcher
153- test $$(du -m $(OUT_DIR ) /launcher|cut -f 1 ) -le 3
154-
155- build-linux-s390x-launcher : $(BUILD_DIR ) /linux-s390x/lifecycle/launcher
156-
157- $(BUILD_DIR ) /linux-s390x/lifecycle/launcher : export GOOS:=linux
158- $(BUILD_DIR ) /linux-s390x/lifecycle/launcher : export GOARCH:=s390x
159- $(BUILD_DIR ) /linux-s390x/lifecycle/launcher : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
160- $(BUILD_DIR ) /linux-s390x/lifecycle/launcher : $(GOFILES )
161- $(BUILD_DIR ) /linux-s390x/lifecycle/launcher :
162- @echo " > Building lifecycle/launcher for $( GOOS) /$( GOARCH) ..."
163- mkdir -p $(OUT_DIR )
164- $(GOENV ) $(GOBUILD ) -o $(OUT_DIR ) /launcher -a ./cmd/launcher
165- test $$(du -m $(OUT_DIR ) /launcher|cut -f 1 ) -le 3
166-
167- build-linux-amd64-symlinks : export GOOS:=linux
168- build-linux-amd64-symlinks : export GOARCH:=amd64
169- build-linux-amd64-symlinks : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
170- build-linux-amd64-symlinks :
171- @echo " > Creating phase symlinks for $( GOOS) /$( GOARCH) ..."
172- ln -sf lifecycle $(OUT_DIR ) /detector
173- ln -sf lifecycle $(OUT_DIR ) /analyzer
174- ln -sf lifecycle $(OUT_DIR ) /restorer
175- ln -sf lifecycle $(OUT_DIR ) /builder
176- ln -sf lifecycle $(OUT_DIR ) /exporter
177- ln -sf lifecycle $(OUT_DIR ) /rebaser
178- ln -sf lifecycle $(OUT_DIR ) /creator
179- ln -sf lifecycle $(OUT_DIR ) /extender
180-
181- build-linux-arm64-symlinks : export GOOS:=linux
182- build-linux-arm64-symlinks : export GOARCH:=arm64
183- build-linux-arm64-symlinks : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
184- build-linux-arm64-symlinks :
185- @echo " > Creating phase symlinks for $( GOOS) /$( GOARCH) ..."
186- ln -sf lifecycle $(OUT_DIR ) /detector
187- ln -sf lifecycle $(OUT_DIR ) /analyzer
188- ln -sf lifecycle $(OUT_DIR ) /restorer
189- ln -sf lifecycle $(OUT_DIR ) /builder
190- ln -sf lifecycle $(OUT_DIR ) /exporter
191- ln -sf lifecycle $(OUT_DIR ) /rebaser
192- ln -sf lifecycle $(OUT_DIR ) /creator
193- ln -sf lifecycle $(OUT_DIR ) /extender
194-
195- build-linux-ppc64le-symlinks : export GOOS:=linux
196- build-linux-ppc64le-symlinks : export GOARCH:=ppc64le
197- build-linux-ppc64le-symlinks : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
198- build-linux-ppc64le-symlinks :
199- @echo " > Creating phase symlinks for $( GOOS) /$( GOARCH) ..."
200- ln -sf lifecycle $(OUT_DIR ) /detector
201- ln -sf lifecycle $(OUT_DIR ) /analyzer
202- ln -sf lifecycle $(OUT_DIR ) /restorer
203- ln -sf lifecycle $(OUT_DIR ) /builder
204- ln -sf lifecycle $(OUT_DIR ) /exporter
205- ln -sf lifecycle $(OUT_DIR ) /rebaser
206- ln -sf lifecycle $(OUT_DIR ) /creator
207- ln -sf lifecycle $(OUT_DIR ) /extender
208-
209- build-linux-s390x-symlinks : export GOOS:=linux
210- build-linux-s390x-symlinks : export GOARCH:=s390x
211- build-linux-s390x-symlinks : OUT_DIR?=$(BUILD_DIR ) /$(GOOS ) -$(GOARCH ) /lifecycle
212- build-linux-s390x-symlinks :
213- @echo " > Creating phase symlinks for $( GOOS) /$( GOARCH) ..."
214- ln -sf lifecycle $(OUT_DIR ) /detector
215- ln -sf lifecycle $(OUT_DIR ) /analyzer
216- ln -sf lifecycle $(OUT_DIR ) /restorer
217- ln -sf lifecycle $(OUT_DIR ) /builder
218- ln -sf lifecycle $(OUT_DIR ) /exporter
219- ln -sf lifecycle $(OUT_DIR ) /rebaser
220- ln -sf lifecycle $(OUT_DIR ) /creator
221- ln -sf lifecycle $(OUT_DIR ) /extender
73+ define build_targets
74+ build-$(1 ) -$(2 ) : build-$(1 ) -$(2 ) -lifecycle build-$(1 ) -$(2 ) -symlinks build-$(1 ) -$(2 ) -launcher
75+
76+ build-$(1 ) -$(2 ) -lifecycle: $(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/lifecycle
77+
78+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/lifecycle: export GOOS:=$(1 )
79+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/lifecycle: export GOARCH:=$(2 )
80+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/lifecycle: OUT_DIR?=$$(BUILD_DIR ) /$$(GOOS ) -$$(GOARCH ) /lifecycle
81+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/lifecycle: $$(GOFILES )
82+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/lifecycle:
83+ @echo "> Building lifecycle/lifecycle for $$(GOOS ) /$$(GOARCH ) ..."
84+ mkdir -p $$(OUT_DIR )
85+ $$(GOENV ) $$(GOBUILD ) -o $$(OUT_DIR ) /lifecycle -a ./cmd/lifecycle
86+
87+ build-$(1 ) -$(2 ) -symlinks: export GOOS:=$(1 )
88+ build-$(1 ) -$(2 ) -symlinks: export GOARCH:=$(2 )
89+ build-$(1 ) -$(2 ) -symlinks: OUT_DIR?=$$(BUILD_DIR ) /$$(GOOS ) -$$(GOARCH ) /lifecycle
90+ build-$(1 ) -$(2 ) -symlinks:
91+ @echo "> Creating phase symlinks for $$(GOOS ) /$$(GOARCH ) ..."
92+ ln -sf lifecycle $$(OUT_DIR ) /detector
93+ ln -sf lifecycle $$(OUT_DIR ) /analyzer
94+ ln -sf lifecycle $$(OUT_DIR ) /restorer
95+ ln -sf lifecycle $$(OUT_DIR ) /builder
96+ ln -sf lifecycle $$(OUT_DIR ) /exporter
97+ ln -sf lifecycle $$(OUT_DIR ) /rebaser
98+ ln -sf lifecycle $$(OUT_DIR ) /creator
99+ ln -sf lifecycle $$(OUT_DIR ) /extender
100+
101+ build-$(1 ) -$(2 ) -launcher: $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/launcher
102+
103+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/launcher: export GOOS:=$(1 )
104+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/launcher: export GOARCH:=$(2 )
105+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/launcher: OUT_DIR?=$$(BUILD_DIR ) /$$(GOOS ) -$$(GOARCH ) /lifecycle
106+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/launcher: $$(GOFILES )
107+ $$(BUILD_DIR ) /$(1 ) -$(2 ) /lifecycle/launcher:
108+ @echo "> Building lifecycle/launcher for $$(GOOS ) /$$(GOARCH ) ..."
109+ mkdir -p $$(OUT_DIR )
110+ $$(GOENV ) $$(GOBUILD ) -o $$(OUT_DIR ) /launcher -a ./cmd/launcher
111+ test $$$$(du -m $$(OUT_DIR ) /launcher|cut -f 1 ) -le 3
112+ endef
113+
114+ $(foreach ga,$(GOOS_ARCHS),$(eval $(call build_targets,$(word 1, $(subst /, ,$(ga))),$(word 2, $(subst /, ,$(ga))))))
222115
223116build-windows-amd64-lifecycle : $(BUILD_DIR ) /windows-amd64/lifecycle/lifecycle.exe
224117
0 commit comments