latest
This commit is contained in:
23
Makefile
23
Makefile
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user