Create makefile
This commit is contained in:
parent
803ab765b9
commit
f448db099d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
# builds
|
# builds
|
||||||
anical
|
anical
|
||||||
|
build/
|
||||||
31
Makefile
Normal file
31
Makefile
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user