Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (62 loc) · 1.83 KB
/
Copy pathMakefile
File metadata and controls
73 lines (62 loc) · 1.83 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
.PHONY: all build build-linux generate clean test run help
# Default target
all: build
# Build for current platform
build:
go build -o packetDup .
go build -o sender ./cmd/sender
go build -o receiver ./cmd/receiver
# Build for Linux (cross-compile)
build-linux:
GOOS=linux GOARCH=amd64 go build -o packetDup-linux .
# Generate eBPF code (Linux only, requires clang/llvm)
generate:
@if [ "$$(uname)" = "Linux" ]; then \
cd proxy/bpf && go generate; \
else \
echo "eBPF code generation is only supported on Linux"; \
fi
# Clean build artifacts
clean:
rm -f packetDup packetDup-linux sender receiver
rm -f proxy/bpf/*.o proxy/bpf/*_bpfel.go proxy/bpf/*_bpfeb.go
# Run tests
test:
go test ./...
# Run with default settings
run:
go run . --engine go
# Run with eBPF engine (Linux only)
run-ebpf:
@if [ "$$(uname)" = "Linux" ]; then \
sudo go run . --engine ebpf; \
else \
echo "eBPF engine is only supported on Linux"; \
fi
# Install dependencies
deps:
go mod tidy
go mod download
# Install eBPF dependencies (Linux only)
deps-ebpf:
@if [ "$$(uname)" = "Linux" ]; then \
go get github.com/cilium/ebpf; \
go get github.com/cilium/ebpf/cmd/bpf2go; \
else \
echo "eBPF dependencies are only needed on Linux"; \
fi
# Help
help:
@echo "PacketDup Makefile"
@echo ""
@echo "Usage:"
@echo " make build - Build for current platform"
@echo " make build-linux - Cross-compile for Linux"
@echo " make generate - Generate eBPF code (Linux only)"
@echo " make clean - Remove build artifacts"
@echo " make test - Run tests"
@echo " make run - Run with Go engine"
@echo " make run-ebpf - Run with eBPF engine (Linux, requires sudo)"
@echo " make deps - Install Go dependencies"
@echo " make deps-ebpf - Install eBPF dependencies (Linux only)"
@echo " make help - Show this help"