-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (81 loc) · 2.95 KB
/
Makefile
File metadata and controls
99 lines (81 loc) · 2.95 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Makefile for msgvault
.DEFAULT_GOAL := help
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -X github.com/wesm/msgvault/cmd/msgvault/cmd.Version=$(VERSION) \
-X github.com/wesm/msgvault/cmd/msgvault/cmd.Commit=$(COMMIT) \
-X github.com/wesm/msgvault/cmd/msgvault/cmd.BuildDate=$(BUILD_DATE)
LDFLAGS_RELEASE := $(LDFLAGS) -s -w
.PHONY: build build-release install clean test test-v fmt lint tidy shootout run-shootout setup-hooks help
# Build the binary (debug)
build:
CGO_ENABLED=1 go build -tags fts5 -ldflags="$(LDFLAGS)" -o msgvault ./cmd/msgvault
@chmod +x msgvault
# Build with optimizations (release)
build-release:
CGO_ENABLED=1 go build -tags fts5 -ldflags="$(LDFLAGS_RELEASE)" -trimpath -o msgvault ./cmd/msgvault
@chmod +x msgvault
# Install to ~/.local/bin, $GOBIN, or $GOPATH/bin
install:
@if [ -d "$(HOME)/.local/bin" ]; then \
echo "Installing to ~/.local/bin/msgvault"; \
CGO_ENABLED=1 go build -tags fts5 -ldflags="$(LDFLAGS)" -o "$(HOME)/.local/bin/msgvault" ./cmd/msgvault; \
else \
INSTALL_DIR="$${GOBIN:-$$(go env GOBIN)}"; \
if [ -z "$$INSTALL_DIR" ]; then \
GOPATH_FIRST="$$(go env GOPATH | cut -d: -f1)"; \
INSTALL_DIR="$$GOPATH_FIRST/bin"; \
fi; \
mkdir -p "$$INSTALL_DIR"; \
echo "Installing to $$INSTALL_DIR/msgvault"; \
CGO_ENABLED=1 go build -tags fts5 -ldflags="$(LDFLAGS)" -o "$$INSTALL_DIR/msgvault" ./cmd/msgvault; \
fi
# Clean build artifacts
clean:
rm -f msgvault msgvault.exe mimeshootout
rm -rf bin/
# Run tests
test:
go test -tags fts5 ./...
# Run tests with verbose output
test-v:
go test -tags fts5 -v ./...
# Format code
fmt:
go fmt ./...
# Run linter
lint:
@which golangci-lint > /dev/null || (echo "Install golangci-lint: https://golangci-lint.run/usage/install/" && exit 1)
golangci-lint run ./...
# Enable pre-commit hook (fmt + lint)
setup-hooks:
git config core.hooksPath .githooks
@echo "Pre-commit hook enabled (.githooks/pre-commit)"
# Tidy dependencies
tidy:
go mod tidy
# Build the MIME shootout tool
shootout:
CGO_ENABLED=1 go build -o mimeshootout ./scripts/mimeshootout
# Run MIME shootout
run-shootout: shootout
./mimeshootout -limit 1000
# Show help
help:
@echo "msgvault build targets:"
@echo ""
@echo " build - Debug build"
@echo " build-release - Release build (optimized, stripped)"
@echo " install - Install to ~/.local/bin or GOPATH"
@echo ""
@echo " test - Run tests"
@echo " test-v - Run tests (verbose)"
@echo " fmt - Format code"
@echo " lint - Run linter"
@echo " tidy - Tidy go.mod"
@echo " setup-hooks - Enable pre-commit hook (fmt + lint)"
@echo " clean - Remove build artifacts"
@echo ""
@echo " shootout - Build MIME shootout tool"
@echo " run-shootout - Run MIME shootout"