Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (67 loc) · 1.97 KB
/
Copy pathMakefile
File metadata and controls
97 lines (67 loc) · 1.97 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
APP=sysmonitor-tool
CFLAGS := -O2 -g -Wall -Werror $(CFLAGS)
BPF_CFLAGS := $(CFLAGS)
EBPF_FILES := monitors/sysstream/bpf/syscalls.ebpf.c \
monitors/sysstream/bpf/sysstream.ebpf.c
GEN_EBPF_FILES := $(shell find . -type f -name '*_bpfe*.go')
GOLANG_FILES := $(shell find . -name '*.go')
EBPF_SRC_FILES := $(shell find . -name '*.ebpf.c')
all: godeps genall build
.PHONY: build
build: $(APP)
$(APP): $(GOLANG_FILES)
CGO_ENABLED=0 go build .
.PHONY: run
run:
sudo ./$(APP)
.PHONY: sum
sum: go.sum
.PHONY: fmt
fmt: sum
go fmt *.go
.PHONY: clean
clean: delete-generated
# Geneate EBPF Files
.PHONY: genall
genall: vmlinuxgen syscallgen gogen
# Geneate EBPF Files
#
.PHONY: gogen
gogen: $(GEN_EBPF_FILES) gogenerate
#case when a source file changes
$(GEN_EBPF_FILES): $(EBPF_SRC_FILES)
go generate ./...
#case when the generated files do not exist
.PHONY: gogenerate
gogenerate:
ifeq ("$(wildcard $(GEN_EBPF_FILES))","")
# go generate $(EBPF_FILES)
go generate ./...
endif
includes/vmlinux.h:
bpftool btf dump file /sys/kernel/btf/vmlinux format c > includes/vmlinux.h
.PHONY: vmlinuxgen
vmlinuxgen: includes/vmlinux.h
# Generate the syscalls name to number mathing for your hardware architecture
# you must have the ausyscall utility installed on your machine for this to work
syscalls/sysnames/syscalls.csv:
-ausyscall --dump > utils/sysnames/syscalls.csv
-sed -i '1d' utils/sysnames/syscalls.csv
.PHONY: syscallgen
syscallgen: utils/sysnames/syscalls.csv
# Used to install go dependencies
godeps: go.sum
go.sum:
go mod download github.com/cilium/ebpf
go get
go get github.com/cilium/ebpf/internal/unix
-find . -type f -name '*_bpfe*.go' -delete
-find . -type f -name '*_bpfe*.o' -delete
#delete all generated files made by go generate
.PHONY: delete-generated
delete-generated:
find . -type f -name '*_bpfe*.go' -delete
find . -type f -name '*_bpfe*.o' -delete
find . -type f -name 'vmlinux.h' -delete
-rm ./syscalls/sysnames/syscalls.csv
-rm $(APP)