-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (46 loc) · 1.4 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
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
DEBUGBPF = -DDEBUG
DEBUGFLAGS = -O0 -g -Wall
PFLAGS = $(DEBUGFLAGS)
TARGETS := xdp_demo
TARGETS_ALL = $(TARGETS)
# Generate file name-scheme based on TARGETS
KERN_SOURCES = ${TARGETS_ALL:=_kern.c}
KERN_OBJECTS = ${KERN_SOURCES:.c=.o}
LINUXINCLUDE += -I./headers
NOSTDINC_FLAGS =
#NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name='include')
EXTRA_CFLAGS =
LLC ?= llc
CLANG ?= clang
CC = gcc
kern: $(KERN_OBJECTS)
# Compiling of eBPF restricted-C code with LLVM
# clang option -S generated output file with suffix .ll
# which is the non-binary LLVM assembly language format
# (normally LLVM bitcode format .bc is generated)
#
# Use -Wno-address-of-packed-member as eBPF verifier enforces
# unaligned access checks where necessary
#
$(KERN_OBJECTS): %.o: %.c Makefile
$(CLANG) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
-D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-O2 -emit-llvm -c -g $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
clean:
@find . -type f \
\( -name '*~' \
-o -name '*.ll' \
-o -name '*.bc' \
-o -name '*.o' \) \
-exec rm -vf '{}' \;
format-c:
find . -regex '.*\.\(c\|h\)' -exec clang-format -style=file -i {} \;
demo-attach:
sudo ip link set lo xdpgeneric obj xdp_demo_kern.o sec xdp
demo-unattach:
sudo ip link set lo xdpgeneric off
demo-map-dump:
sudo bpftool map dump name xdp_demo_stats -pj
demo-test:
ping -c 5 127.0.0.8