Skip to content

Commit abb677d

Browse files
vdemeestertekton-robot
authored andcommitted
Makefile: add a cross target 🌵
This will allow building for different target (x86_64, arm, arm64, s390x and ppc64le). This doesn't mean we support those architecture (especially as `ko` doesn't really support multi-arch for now). But it is nice to be able to see if our code compiles and can be package (manually, *unofficially*, for those target). A check will be added in plumbing so that we validate that, at least, a PR doesn't break those. Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
1 parent 4772854 commit abb677d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎Makefile

+24
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,29 @@ FORCE:
4040
bin/%: cmd/% FORCE
4141
$(GO) build -mod=vendor $(LDFLAGS) -v -o $@ ./$<
4242

43+
.PHONY: cross
44+
cross: amd64 arm arm64 s390x ppc64le ## build cross platform binaries
45+
46+
.PHONY: amd64
47+
amd64:
48+
GOOS=linux GOARCH=amd64 go build -mod=vendor $(LDFLAGS) ./cmd/...
49+
50+
.PHONY: arm
51+
arm:
52+
GOOS=linux GOARCH=arm go build -mod=vendor $(LDFLAGS) ./cmd/...
53+
54+
.PHONY: arm64
55+
arm64:
56+
GOOS=linux GOARCH=arm64 go build -mod=vendor $(LDFLAGS) ./cmd/...
57+
58+
.PHONY: s390x
59+
s390x:
60+
GOOS=linux GOARCH=s390x go build -mod=vendor $(LDFLAGS) ./cmd/...
61+
62+
.PHONY: ppc64le
63+
ppc64le:
64+
GOOS=linux GOARCH=ppc64le go build -mod=vendor $(LDFLAGS) ./cmd/...
65+
4366
KO = $(BIN)/ko
4467
$(BIN)/ko: PACKAGE=github.com/google/ko/cmd/ko
4568

@@ -173,6 +196,7 @@ fmt: ; $(info $(M) running gofmt…) @ ## Run gofmt on all source files
173196
.PHONY: clean
174197
clean: ; $(info $(M) cleaning…) @ ## Cleanup everything
175198
@rm -rf $(BIN)
199+
@rm -rf bin
176200
@rm -rf test/tests.* test/coverage.*
177201

178202
.PHONY: help

0 commit comments

Comments
 (0)