Create makefile

This commit is contained in:
Uthman Fatih 2026-11-02 22:22:22 +00:00
parent 803ab765b9
commit f448db099d
3 changed files with 33 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
# builds
anical
build/

31
Makefile Normal file
View File

@ -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

View File

@ -55,4 +55,3 @@ func main() {
log.Debug("Debug logging enabled")
log.Infof("Starting AniCal")
}