summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-11 14:47:10 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-11 15:01:57 +0200
commit42b02c47be9b285099203e44a2570636d4ca6f03 (patch)
tree82bcb9e19bd886f36e1ca7b2d94a204c988f1fd1 /Makefile
downloadkrino-42b02c47be9b285099203e44a2570636d4ca6f03.tar.gz
krino-42b02c47be9b285099203e44a2570636d4ca6f03.zip
krino: foundation — sexp reader, config language, init/new/check
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile55
1 files changed, 55 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9dfc7d4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+# Works with GNU make and BSD make.
+
+DESTDIR ?=
+PREFIX ?= $(HOME)/.local
+BINDIR = $(DESTDIR)$(PREFIX)/bin
+BIN = krino
+VERSION != git describe --tags --always --dirty 2>/dev/null || echo dev
+LDFLAGS = -s -w -X main.version=$(VERSION)
+
+.PHONY: all help build install uninstall test vet fmt ci install-hooks clean
+
+all: build
+
+help: ## show this help
+ @grep -E '^[a-z-]+:.*## ' Makefile | \
+ awk 'BEGIN {FS = ":.*## "}; {printf " %-10s %s\n", $$1, $$2}'
+ @echo " version: $(VERSION) prefix: $(PREFIX)"
+
+build: ## build ./krino; Go fetches module dependencies itself
+ CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN) ./cmd/krino
+
+install: build ## install to $(PREFIX)/bin
+ mkdir -p $(BINDIR)
+ rm -f $(BINDIR)/$(BIN)
+ install -m 755 $(BIN) $(BINDIR)/$(BIN)
+
+uninstall: ## remove the installed binary
+ rm -f $(BINDIR)/$(BIN)
+
+test: ## run the tests
+ go test ./...
+
+vet: ## go vet
+ go vet ./...
+
+fmt: ## gofmt the tree
+ gofmt -w .
+
+ci: ## the gate: gofmt, vet, tests, dependencies, no personal data staged
+ @test -z "$$(gofmt -l .)" || { echo "gofmt needed:"; gofmt -l .; exit 1; }
+ go vet ./...
+ GOOS=freebsd CGO_ENABLED=0 go vet ./...
+ GOOS=openbsd CGO_ENABLED=0 go vet ./...
+ go test ./...
+ @deps=$$(go list -deps ./... | grep -E '^[a-z0-9-]+\.[a-z]+/' | grep -vE '^golang\.org/x/(term|text|sys)(/|$$)' || true); \
+ test -z "$$deps" || { echo "unexpected dependencies:"; echo "$$deps"; exit 1; }
+ @scripts/leak-check
+ @echo "ci ok"
+
+install-hooks: ## install the pre-commit hook that runs the leak check
+ install -m 755 scripts/hooks/pre-commit "$$(git rev-parse --git-path hooks)/pre-commit"
+
+clean: ## remove build output
+ rm -f $(BIN)