Created
February 13, 2022 04:43
-
-
Save bryanjhv/05762f3d931d839b807535c5b2bca3cf to your computer and use it in GitHub Desktop.
Golang multi-arch makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLATFORMS := windows/386 windows/amd64 linux/386 linux/amd64 linux/arm linux/arm64 | |
export CGO_ENABLED = 0 | |
export GO386 = softfloat | |
parts = $(subst /, ,$@) | |
export GOOS = $(word 1,$(parts)) | |
export GOARCH = $(word 2,$(parts)) | |
export EXT = $(if $(filter windows,$(GOOS)),exe,bin) | |
release: clean $(PLATFORMS) | |
clean: | |
rm -rf bin | |
mkdir -p bin | |
$(PLATFORMS): | |
go build -ldflags="-s -w" -o "bin/program-$(GOOS)_$(GOARCH).$(EXT)" . | |
.PHONY: clean release $(PLATFORMS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment