-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·50 lines (37 loc) · 1.11 KB
/
Makefile
File metadata and controls
executable file
·50 lines (37 loc) · 1.11 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
CC := clang
BPF_CC := clang
BDIR := build
SRCDIR := src
KDIR := kernel
IDIR := include
CDIR := common
CFLAGS := -Wall -O2 -g -I$(IDIR) -I$(CDIR)
LDFLAGS := -static -luring -lbpf -lelf -lz -lzstd
BPF_CFLAGS := -target bpf -D__TARGET_ARCH_x86 -I$(CDIR) -I$(KDIR) -O2 -g
USER_SRC := $(wildcard $(SRCDIR)/*.c)
USER_OBJ := $(USER_SRC:$(SRCDIR)/%.c=$(BDIR)/%.o)
USER_BIN := $(BDIR)/volg
BPF_SRC := $(KDIR)/xdp_prog.c
BPF_OBJ := $(BDIR)/xdp_prog.o
BLOB_H := $(CDIR)/xdp_blob.h
.PHONY: all setup clean
all: setup $(BPF_OBJ) $(BLOB_H) $(USER_BIN)
setup:
@mkdir -p $(BDIR)
# 1. Compilation BPF
$(BPF_OBJ): $(BPF_SRC)
@echo "[+] Compiling BPF object: $<"
$(BPF_CC) $(BPF_CFLAGS) -c $< -o $@
$(BLOB_H): $(BPF_OBJ)
@echo "[+] Generating BPF blob header: $@"
@xxd -i $< > $@
$(BDIR)/%.o: $(SRCDIR)/%.c $(BLOB_H)
@echo "[+] Compiling User object: $<"
$(CC) $(CFLAGS) -c $< -o $@
# 4. Linkage
$(USER_BIN): $(USER_OBJ)
@echo "[!] Linking binary: $@"
$(CC) $(USER_OBJ) -o $@ $(LDFLAGS)
clean:
@echo "[-] Cleaning up..."
rm -rf $(BDIR) $(BLOB_H)