-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
49 lines (34 loc) · 1.19 KB
/
Copy pathmakefile
File metadata and controls
49 lines (34 loc) · 1.19 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
# netlib
#
# "make" builds the user space tools in build/, "make test" checks them and
# "make run" builds the xdp detector and attaches it, which needs root.
CC ?= gcc
CLANG ?= clang
CFLAGS ?= -std=gnu11 -O2 -Wall -Wextra
BPF_CFLAGS ?= -O2 -Wall -target bpf
BUILD ?= build
TOOLS := $(BUILD)/netchecksum $(BUILD)/netdump $(BUILD)/netifinfo
NETUTIL := tools/netutil.c tools/netutil.h
.PHONY: all tools test detector run clean
all: tools
tools: $(TOOLS)
$(BUILD)/netchecksum: tools/checksum.c $(NETUTIL) | $(BUILD)
$(CC) $(CFLAGS) -o $@ tools/checksum.c tools/netutil.c
$(BUILD)/netdump: tools/pktdump.c $(NETUTIL) | $(BUILD)
$(CC) $(CFLAGS) -o $@ tools/pktdump.c tools/netutil.c
$(BUILD)/netifinfo: tools/ifinfo.c $(NETUTIL) | $(BUILD)
$(CC) $(CFLAGS) -o $@ tools/ifinfo.c tools/netutil.c
$(BUILD):
mkdir -p $(BUILD)
test: tools
tools/tests.sh $(BUILD)
# The detector needs clang for the bpf target and libbpf for the loader.
detector: detector.bpf.o loader
detector.bpf.o: detector/detector.c
$(CLANG) $(BPF_CFLAGS) -c detector/detector.c -o detector.bpf.o
loader: detector/loader.c
$(CC) detector/loader.c -o loader -lbpf
run: detector
sudo ./loader
clean:
rm -rf $(BUILD) detector.bpf.o loader