-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (29 loc) · 856 Bytes
/
Makefile
File metadata and controls
40 lines (29 loc) · 856 Bytes
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
TARGET = hs_trace
ARCH = $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/')
BPF_OBJ = ${TARGET:=.bpf.o}
USER_C = ${TARGET:=.c}
USER_SKEL = ${TARGET:=.skel.h}
COMMON_H = ${TARGET:=.h}
app: $(TARGET) $(BPF_OBJ)
.PHONY: app
install: $(TARGET) $(BPF_OBJ)
sudo install -o root -m 4755 hs_trace /usr/local/bin
$(TARGET): $(USER_C) $(USER_SKEL) $(COMMON_H)
gcc -Wall -o $(TARGET) $(USER_C) -L../libbpf/src -l:libbpf.a -lelf -lz
%.bpf.o: %.bpf.c vmlinux.h $(COMMON_H)
clang \
-target bpf \
-D __BPF_TRACING__ \
-D __TARGET_ARCH_$(ARCH) \
-Wall \
-I/usr/include/$(shell uname -m)-linux-gnu \
-O2 -g -o $@ -c $<
llvm-strip -g $@
$(USER_SKEL): $(BPF_OBJ)
bpftool gen skeleton $< > $@
vmlinux.h:
bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
clean:
- rm $(BPF_OBJ)
- rm $(TARGET)
- rm $(USER_SKEL)