Skip to content

Commit

Permalink
Build native ARM binary for M1
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Mar 6, 2021
1 parent 17b0da6 commit 934f81a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ VERSION:=$(shell git describe --tags --always --dirty="-dev")
GOOS:=$(shell go env GOOS)
LDFLAGS:=-X main.Version=$(VERSION) -w -s
GOOS:=$(strip $(shell go env GOOS))
GOARCH:=$(strip $(shell go env GOARCH))
GOARCHs:=$(strip $(shell go env GOARCH))

ifeq "$(GOOS)" "windows"
SUFFIX=.exe
endif

ifeq "$(GOOS)" "darwin"
GOARCHs=amd64 arm64
endif

# CGO must be enabled
export CGO_ENABLED:=1

build: fmt vet
go build -mod=vendor -ldflags="$(LDFLAGS)" -o bin/$(APP_NAME)_$(GOOS)_$(GOARCH)$(SUFFIX) ./cmd/gof5
$(foreach GOARCH,$(GOARCHs),$(shell GOARCH=$(GOARCH) go build -mod=vendor -ldflags="$(LDFLAGS)" -o bin/$(APP_NAME)_$(GOOS)_$(GOARCH)$(SUFFIX) ./cmd/gof5))

docker:
docker run -ti --rm -e GOCACHE=/tmp -v $(PWD):/$(APP_NAME) -u $(UID):$(UID) --workdir /$(APP_NAME) golang:latest make
Expand Down

0 comments on commit 934f81a

Please sign in to comment.