This commit is contained in:
2025-05-01 03:11:54 -07:00
parent b63bab0582
commit 2e8bbfee34
9 changed files with 247 additions and 17 deletions

View File

@@ -1,16 +1,21 @@
# Infer VERSION from the most recent tag; if none, use short commit hash.
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || \
git rev-parse --short HEAD)
# -------- version detection -------------------------------------------------
# Use latest annotated/lightweight tag; if none, fall back to short SHA.
VERSION ?= $(shell git describe --tags --always --dirty=-dirty 2>/dev/null)
GOLDFLAGS += -s -w \
-X 'git.eeqj.de/sneak/sysinfo/internal/sysinfo.Version=$(VERSION)'
# -------- linker flags -------------------------------------------------------
# No inner quotes around -X value — go tool handles the spaces correctly.
LDFLAGS = -s -w -X "git.eeqj.de/sneak/sysinfo/internal/sysinfo.Version=$(VERSION)"
all: build
# -------- generic go build/install ------------------------------------------
PKG_CMD = ./cmd/sysinfo
build:
GOFLAGS=-ldflags="$(GOLDFLAGS)" go build ./cmd/sysinfo
go build -ldflags '$(LDFLAGS)' $(PKG_CMD)
install:
GOFLAGS=-ldflags="$(GOLDFLAGS)" go install ./cmd/sysinfo
go install -ldflags '$(LDFLAGS)' $(PKG_CMD)
.PHONY: all build install
clean:
rm -f sysinfo
.PHONY: build install clean