Skip to content

Commit

Permalink
fix(Makefile): use native GOOS/GOARCH by default (#488)
Browse files Browse the repository at this point in the history
Co-authored-by: danielpaulus <[email protected]>
  • Loading branch information
ardnew and danielpaulus authored Nov 13, 2024
1 parent 1caa612 commit 0ea513c
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,19 @@
GO_IOS_BINARY_NAME=ios
NCM_BINARY_NAME=go-ncm

# Define only if compiling for system different than our own
OS=
ARCH=

# Detect the system architecture
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)

# Default GOARCH value
GOARCH := amd64

# Set GOARCH based on the detected architecture
ifeq ($(UNAME_M),x86_64)
GOARCH := amd64
else ifeq ($(UNAME_M),armv7l)
GOARCH := arm
else ifeq ($(UNAME_M),aarch64)
GOARCH := arm64
# Add more architecture mappings as needed
endif
# Prepend each non-empty OS/ARCH definition to "go" command
GOEXEC=$(strip $(foreach v,OS ARCH,$(and $($v),GO$v=$($v) )) go)

# Build the Go program
build:
@go work use .
@GOARCH=$(GOARCH) go build -o $(GO_IOS_BINARY_NAME) ./main.go
@go work use ./ncm
@CGO_ENABLED=1 GOARCH=$(GOARCH) go build -o $(NCM_BINARY_NAME) ./cmd/cdc-ncm/main.go
@$(GOEXEC) work use .
@$(GOEXEC) build -o $(GO_IOS_BINARY_NAME) ./main.go
@$(GOEXEC) work use ./ncm
@CGO_ENABLED=1 $(GOEXEC) build -o $(NCM_BINARY_NAME) ./cmd/cdc-ncm/main.go

# Run the Go program with sudo
run: build
Expand Down

0 comments on commit 0ea513c

Please sign in to comment.