diff --git a/.gitignore b/.gitignore index b53db6f..b3dba95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # builds -anical \ No newline at end of file +anical +build/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..855fadb --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +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 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 only; 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-$$(uname -m) + +clean: + rm -rf build \ No newline at end of file diff --git a/main.go b/main.go index be3e812..eebcd91 100644 --- a/main.go +++ b/main.go @@ -55,4 +55,3 @@ func main() { log.Debug("Debug logging enabled") log.Infof("Starting AniCal") } -