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) <noreply@anthropic.com>
38 lines
1.1 KiB
Makefile
38 lines
1.1 KiB
Makefile
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"
|