Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
142 lines (121 loc) · 4.96 KB
/
Copy pathMakefile
File metadata and controls
142 lines (121 loc) · 4.96 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# =============================================================================
# Heimdall — Kernel-level entropy-based ransomware detection
# =============================================================================
#
# Usage:
# make build Build all workspace crates (release)
# make test Run unit and integration tests
# make install Install to system (requires sudo)
# make uninstall Remove from system (requires sudo)
# make e2e Run end-to-end tests (requires sudo)
# make harness Run the test harness
# make package-deb Build Debian package
# make package-rpm Build RPM package
# make clean Remove build artifacts
# make fmt Format code
# make lint Run clippy
# make check Format check + clippy + test
# make help Show this help
# =============================================================================
.PHONY: build test install uninstall e2e harness package-deb package-rpm \
clean fmt lint check help
# ---------------------------------------------------------------------------
# Configuration
# ---------------------------------------------------------------------------
CARGO ?= cargo
PREFIX ?= /usr/local
BINDIR := $(PREFIX)/bin
RELEASE_DIR := target/release
INSTALL_OPTS ?=
BINARIES := heimdalld heimdall heimdall-tui heimdall-harness
# Cargo flags
CARGO_FLAGS := --release --workspace --exclude heimdall-ebpf
# ---------------------------------------------------------------------------
# Default target
# ---------------------------------------------------------------------------
all: build
# ---------------------------------------------------------------------------
# Build
# ---------------------------------------------------------------------------
build:
$(CARGO) build $(CARGO_FLAGS)
build-debug:
$(CARGO) build --workspace --exclude heimdall-ebpf
# ---------------------------------------------------------------------------
# Test
# ---------------------------------------------------------------------------
test:
$(CARGO) test --workspace --exclude heimdall-ebpf
e2e: build
@if [ ! -f tests/e2e/run_e2e.sh ]; then \
echo "End-to-end test runner not found: tests/e2e/run_e2e.sh"; \
exit 1; \
fi
sudo tests/e2e/run_e2e.sh --skip-build
harness: build
./$(RELEASE_DIR)/heimdall-harness all
# ---------------------------------------------------------------------------
# Install / Uninstall
# ---------------------------------------------------------------------------
install: build
sudo scripts/install.sh --no-build --from-source . $(INSTALL_OPTS)
uninstall:
sudo scripts/install.sh --uninstall
upgrade: build
sudo scripts/install.sh --upgrade --no-build --from-source .
# ---------------------------------------------------------------------------
# Packaging
# ---------------------------------------------------------------------------
package-deb: build
./packaging/deb/build-deb.sh
package-rpm: build
./packaging/rpm/build-rpm.sh
# ---------------------------------------------------------------------------
# Code quality
# ---------------------------------------------------------------------------
fmt:
$(CARGO) fmt --all
fmt-check:
$(CARGO) fmt --all -- --check
lint:
$(CARGO) clippy --workspace --exclude heimdall-ebpf -- -D warnings
check: fmt-check lint test
@echo ""
@echo "All checks passed."
# ---------------------------------------------------------------------------
# Clean
# ---------------------------------------------------------------------------
clean:
$(CARGO) clean
rm -rf /tmp/heimdall-test-*
rm -f packaging/deb/heimdall_*.deb
rm -rf packaging/deb/heimdall_*/
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
help:
@echo ""
@echo "Heimdall Makefile targets:"
@echo ""
@echo " build Build all workspace crates (release mode)"
@echo " build-debug Build all workspace crates (debug mode)"
@echo " test Run unit and integration tests"
@echo " e2e Run end-to-end tests (requires sudo)"
@echo " harness Run the test harness"
@echo " install Build and install to system (requires sudo)"
@echo " uninstall Remove from system (requires sudo)"
@echo " upgrade Upgrade existing installation (requires sudo)"
@echo " package-deb Build Debian .deb package"
@echo " package-rpm Build RPM package"
@echo " fmt Format all code with rustfmt"
@echo " fmt-check Check formatting without modifying"
@echo " lint Run clippy linter"
@echo " check Run fmt-check + lint + test"
@echo " clean Remove build artifacts"
@echo " help Show this help"
@echo ""
@echo "Variables:"
@echo " PREFIX Install prefix [default: /usr/local]"
@echo " CARGO Cargo command [default: cargo]"
@echo " INSTALL_OPTS Extra options for install.sh"
@echo ""