From 0862dc8343fae9aa6e99bb7f14974415973f1aac Mon Sep 17 00:00:00 2001 From: mpenning Date: Tue, 10 Oct 2023 05:16:44 -0500 Subject: [PATCH] Add platform-specific builds --- dev_tools/deploy_docs/Makefile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dev_tools/deploy_docs/Makefile b/dev_tools/deploy_docs/Makefile index f5865fa2..69099ab5 100644 --- a/dev_tools/deploy_docs/Makefile +++ b/dev_tools/deploy_docs/Makefile @@ -13,6 +13,9 @@ GOOS=linux # Good primer on Makefile variables... # https://earthly.dev/blog/makefile-variables/ GO_SOURCE_FILE=src/deploy_docs.go +GO_BINARY_FILE=deploy_docs +# Find the platform (Linux or Darwin) from 'uname -a'... +PLATFORM := $(shell perl -e '`uname -a` =~ /^(\w+).*?$$/;print("$$1");') .DEFAULT_GOAL := build @@ -32,7 +35,22 @@ build: make dep -make lint cd src && go vet . - go build -o bin/deploy_docs -ldflags="-s -w" $(GO_SOURCE_FILE) + + ############################################################################ + # + # Replace this line with PLATFORM detection... + # + #go build -o bin/deploy_docs -ldflags="-s -w" $(GO_SOURCE_FILE) + # + ############################################################################ + if [ "$(PLATFORM)" = "Linux" ]; then \ + GOARCH=amd64 GOOS=linux go build -ldflags "-s -w" -o ./$(GO_BINARY_FILE) $(GO_SOURCE_FILE); \ + elif [ "$(PLATFORM)" = "Darwin" ]; then \ + GOARCH=amd64 GOOS=darwin go build -ldflags "-s -w" -o ./$(GO_BINARY_FILE) $(GO_SOURCE_FILE); \ + else \ + echo "$(COL_RED)Unknown PLATFORM -> $(PLATFORM)$(COL_END)"; \ + fi + make release .PHONY: build deploy: