From ba45629bf101b53d114571a23057108028505cba Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Tue, 28 Apr 2026 21:55:26 +0200 Subject: [PATCH] Add Makefile with build, test, lint, run, and clean targets Standard targets: - build: compiles cmd/librenotes with version/buildtime ldflags - test: race detector enabled, full module - lint: go vet, plus staticcheck if available - run: build + execute, ARGS forwarded - clean: remove binary and test/coverage artifacts Variables (BINARY, OUTDIR, GO, GOFLAGS, LDFLAGS, TESTFLAGS) are overridable so the CI workflow (#5) can invoke targets with custom output paths or flags. Closes #38. Co-Authored-By: Claude Opus 4.7 (1M context) --- Makefile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ef00bb7 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +BINARY ?= librenotes +OUTDIR ?= . +CMD_PKG ?= ./cmd/librenotes +GO ?= go +GOFLAGS ?= +LDFLAGS ?= -X git.librete.ch/public/librenotes/internal/notesium.gitversion=$(shell git describe --tags --always --dirty 2>/dev/null || echo dev) \ + -X git.librete.ch/public/librenotes/internal/notesium.buildtime=$(shell date -u +%Y-%m-%dT%H:%M:%SZ) +TESTFLAGS ?= -race -count=1 + +.PHONY: all build test lint run clean help + +all: build + +build: + $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(OUTDIR)/$(BINARY) $(CMD_PKG) + +test: + $(GO) test $(TESTFLAGS) ./... + +lint: + $(GO) vet ./... + @command -v staticcheck >/dev/null 2>&1 && staticcheck ./... || echo "staticcheck not installed, skipping" + +run: build + $(OUTDIR)/$(BINARY) $(ARGS) + +clean: + rm -f $(OUTDIR)/$(BINARY) + rm -f *.test *.out coverage.out + +help: + @echo "Targets:" + @echo " build - compile binary to \$$OUTDIR/\$$BINARY (default ./librenotes)" + @echo " test - run all Go tests with race detector" + @echo " lint - run go vet (+ staticcheck if installed)" + @echo " run - build and run; pass args via ARGS=\"...\"" + @echo " clean - remove build artifacts"