32 lines
998 B
Makefile
32 lines
998 B
Makefile
VERSION ?= $(shell git describe --tags --always --dirty)
|
|
LDFLAGS := -s -w -X main.version=$(VERSION)
|
|
PLATFORMS := linux/amd64 linux/arm64 windows/amd64
|
|
|
|
.PHONY: all cross darwin package clean
|
|
|
|
all:
|
|
# Release build for the host platform
|
|
mkdir -p build
|
|
CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o build/anical
|
|
|
|
cross:
|
|
# Pure-Go targets; darwin is built separately on macOS
|
|
mkdir -p build
|
|
@for p in $(PLATFORMS); do \
|
|
os=$${p%/*}; arch=$${p#*/}; \
|
|
ext=""; [ "$$os" = "windows" ] && ext=".exe"; \
|
|
echo "building $$os/$$arch"; \
|
|
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build -trimpath \
|
|
-ldflags="$(LDFLAGS)" \
|
|
-o build/anical-$(VERSION)-$$os-$$arch$$ext || exit 1; \
|
|
done
|
|
|
|
darwin:
|
|
# Must run on macOS: systray needs cgo (Cocoa/Objective-C)
|
|
@test "$$(uname -s)" = "Darwin" || { echo "darwin target must run on macOS"; exit 1; }
|
|
mkdir -p build
|
|
go build -trimpath -ldflags="$(LDFLAGS)" \
|
|
-o build/anical-$(VERSION)-darwin-$$(go env GOARCH)
|
|
|
|
clean:
|
|
rm -rf build
|