blob: 40c3ad25bcb2e4f3f1ff427a852e68b389bb24de (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
.POSIX:
DESTDIR=$(HOME)
PREFIX=/.local
INSTALL_PATH=$(DESTDIR)$(PREFIX)/bin
BIN=prognosis
DIST=dist
.PHONY: help build install uninstall test vet fmt ci cross clean
help: ## show this help
@grep -E '^[a-z-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[1m%-16s\033[0m %s\n", $$1, $$2}'
build: ## build the Go binary into ./$(BIN)
go build -trimpath -ldflags "-s -w" -o $(BIN) ./cmd/prognosis
install: build ## build and install the Go binary
mkdir -p $(INSTALL_PATH)
# rm first: the target may be a symlink into this repo (see `link`), and cp
# follows symlinks -- it would write the binary over bin/prognosis itself.
rm -f $(INSTALL_PATH)/$(BIN)
cp $(BIN) $(INSTALL_PATH)/$(BIN)
chmod 755 $(INSTALL_PATH)/$(BIN)
@echo "Installed. Config: $$($(INSTALL_PATH)/$(BIN) -config)"
uninstall: ## remove the installed binary
rm -f $(INSTALL_PATH)/$(BIN)
test: ## run the tests
go test ./...
vet: ## go vet
go vet ./...
fmt: ## gofmt the tree
gofmt -w .
ci: ## pre-push gate: gofmt clean, vet, tests, no third-party deps
@test -z "$$(gofmt -l .)" || { echo "gofmt needed:"; gofmt -l .; exit 1; }
go vet ./...
go test ./...
@deps=$$(go list -deps ./... | grep -E '^[a-z0-9-]+\.[a-z]+/' | grep -v '^github.com/lukaszkasprzak/prognosis' || true); \
test -z "$$deps" || { echo "third-party dependencies crept in:"; echo "$$deps"; exit 1; }
@echo "ci ok"
cross: ## cross-compile into $(DIST)/ -- android/arm64 is the phone
mkdir -p $(DIST)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o $(DIST)/$(BIN)-linux-amd64 ./cmd/prognosis
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o $(DIST)/$(BIN)-linux-arm64 ./cmd/prognosis
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o $(DIST)/$(BIN)-android-arm64 ./cmd/prognosis
@ls -la $(DIST)
clean: ## remove build artifacts
rm -rf $(BIN) $(DIST)
|