-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (52 loc) · 1.51 KB
/
Makefile
File metadata and controls
63 lines (52 loc) · 1.51 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
CLANG ?= clang
CFLAGS := -O2 -g -Wall -Werror
BPF_SRC := bpf/bpf_eghostbuster.c
BPF_HEADERS := -I./bpf/include
OUTPUT_DIR := pkg/bpf
BINARY := eghostbuster
VMLINUX_H := bpf/include/vmlinux.h
# Default target
.PHONY: all
all: build
.PHONY: vmlinux
vmlinux: $(VMLINUX_H)
# Only regenerate if missing
$(VMLINUX_H):
bpftool btf dump file /sys/kernel/btf/vmlinux format c > $@
.PHONY: generate
generate: $(VMLINUX_H)
go run github.com/cilium/ebpf/cmd/bpf2go \
-cc $(CLANG) \
-cflags "$(CFLAGS)" \
-target amd64 \
-go-package bpf \
-output-dir $(OUTPUT_DIR) \
EGhostBuster $(BPF_SRC) \
-- $(BPF_HEADERS)
.PHONY: build
build: generate
CGO_ENABLED=0 go build -o $(BINARY) .
.PHONY: run
run: build
sudo ./$(BINARY)
.PHONY: clean
clean:
rm -f $(OUTPUT_DIR)/eghostbuster_*.go
rm -f $(OUTPUT_DIR)/eghostbuster_*.o
rm -f $(BINARY)
.PHONY: clean-all
clean-all: clean
rm -f $(VMLINUX_H)
.PHONY: docker
docker:
docker build -t eghostbuster:latest .
.PHONY: help
help:
@echo "Targets:"
@echo " build - Generate BPF and build binary (default)"
@echo " generate - Generate Go code from BPF"
@echo " vmlinux - Generate vmlinux.h"
@echo " run - Build and run with sudo"
@echo " docker - Build Docker image"
@echo " clean - Remove build artifacts"
@echo " clean-all - Remove all generated files including vmlinux.h"