-
Notifications
You must be signed in to change notification settings - Fork 104
/
Makefile
28 lines (21 loc) · 1.04 KB
/
Makefile
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
APPS = hello execsnoop execsnoop_v2 bashreadline hello_btf block_shell xdppass tc_block_tcp http_trace https_trace https_trace_bad xdp_drop_test xdp_drop xdp_drop_trace
bpftool = $(shell which bpftool || ../tools/bpftool)
LIBBPF_SRC := $(abspath ../libbpf/src)
LIBBPF_OBJ := $(abspath libbpf/libbpf.a)
INCLUDES := -Ilibbpf/usr/include -I../libbpf/include/uapi -I/usr/include/x86_64-linux-gnu -I.
.PHONY: all
all: $(APPS)
$(APPS): %: %.bpf.c %.c $(LIBBPF_OBJ) $(wildcard %.h)
clang -g -O2 -target bpf -D__TARGET_ARCH_x86 $(INCLUDES) -c [email protected] -o [email protected]
$(bpftool) gen skeleton [email protected] > [email protected]
clang -g -O2 -Wall $(INCLUDES) -c [email protected] -o [email protected]
clang -Wall -O2 -g [email protected] -static $(LIBBPF_OBJ) -lelf -lz -lzstd -o $@
vmlinux:
$(bpftool) btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
libbpf: $(LIBBPF_OBJ)
$(LIBBPF_OBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile)
make -C $(LIBBPF_SRC) BUILD_STATIC_ONLY=1 OBJDIR=$(dir $@) DESTDIR=$(dir $@) install
format:
VERSION_CONTROL=none indent -linux *.h *.c
clean:
rm -rf $(APPS) *.o