Skip to content

Commit

Permalink
build: use GOOS and GOARCH of the build host in 'make build'
Browse files Browse the repository at this point in the history
Signed-off-by: Anjan Nath <kaludios@gmail.com>
  • Loading branch information
anjannath authored and adrianriobo committed Jul 22, 2024
1 parent 87a511e commit 11e15d1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ SOURCES := $(shell find . -name "*.go" -not -path "./vendor/*")
# LDFLAGS := $(VERSION_VARIABLES) -extldflags='-static' ${GO_EXTRA_LDFLAGS}
LDFLAGS := $(VERSION_VARIABLES) ${GO_EXTRA_LDFLAGS}
GCFLAGS := all=-N -l
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)

TOOLS_DIR := tools
include tools/tools.mk
Expand All @@ -37,7 +39,7 @@ install: $(SOURCES)
go install -ldflags="$(LDFLAGS)" $(GO_EXTRA_BUILDFLAGS) ./cmd/mapt

$(BUILD_DIR)/mapt: $(SOURCES)
GOOS=linux GOARCH=amd64 go build -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/mapt $(GO_EXTRA_BUILDFLAGS) ./cmd/mapt
GOOS="$(GOOS)" GOARCH=$(GOARCH) go build -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/mapt $(GO_EXTRA_BUILDFLAGS) ./cmd/mapt

.PHONY: build
build: $(BUILD_DIR)/mapt
Expand Down

0 comments on commit 11e15d1

Please sign in to comment.