-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
32 lines (24 loc) · 924 Bytes
/
Makefile
File metadata and controls
32 lines (24 loc) · 924 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
CLANG ?= clang
GCC ?= gcc
BPFTOOL ?= bpftool
ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/')
BPF_CFLAGS := -g -O2 -target bpf -D__TARGET_ARCH_$(ARCH)
CFLAGS := -g -O2 -Wall
LDLIBS := -lbpf -lelf -lz
.PHONY: all clean
all: kern_error_monitor
# Generate vmlinux.h from running kernel's BTF
vmlinux.h:
$(BPFTOOL) btf dump file /sys/kernel/btf/vmlinux format c > $@
# Compile BPF program
kern_error_monitor.bpf.o: kern_error_monitor.bpf.c kern_error_monitor.h vmlinux.h
$(CLANG) $(BPF_CFLAGS) -c $< -o $@
# Generate BPF skeleton header
kern_error_monitor.skel.h: kern_error_monitor.bpf.o
$(BPFTOOL) gen skeleton $< > $@
# Compile userspace daemon
kern_error_monitor: kern_error_monitor.c kern_error_monitor.h kern_error_monitor.skel.h
$(GCC) $(CFLAGS) -o $@ $< $(LDLIBS)
clean:
rm -f kern_error_monitor kern_error_monitor.bpf.o \
kern_error_monitor.skel.h vmlinux.h