Skip to content

Commit

Permalink
build: detect os/arch more makily
Browse files Browse the repository at this point in the history
  • Loading branch information
gulducat committed Apr 22, 2024
1 parent a405996 commit a942207
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@ GIT_COMMIT = $$(git rev-parse --short HEAD)
GIT_DIRTY = $$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)
GO_LDFLAGS := "$(GO_LDFLAGS) -X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY)"

OS = $(strip $(shell echo -n $${GOOS:-$$(uname | tr [[:upper:]] [[:lower:]])}))
ARCH = $(strip $(shell echo -n $${GOARCH:-$$(A=$$(uname -m); if [ $$A = x86_64 ]; then A=amd64; elif [ $$A = aarch64 ]; then A=arm64; fi; echo $$A)}))
ifdef GOOS
OS = $(GOOS)
else
OS := $(shell uname | tr [[:upper:]] [[:lower:]])
endif

MACHINE = $(shell uname -m)
ifdef GOARCH
ARCH = $(GOARCH)
else ifeq ($(MACHINE),aarch64)
ARCH = arm64
else ifeq ($(MACHINE),x86_64)
ARCH = amd64
endif

PLATFORM ?= $(OS)/$(ARCH)
DIST = dist/$(PLATFORM)
Expand Down

0 comments on commit a942207

Please sign in to comment.