-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (51 loc) · 1.58 KB
/
Copy pathMakefile
File metadata and controls
72 lines (51 loc) · 1.58 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
CC = clang
STATIC ?= 1
BUILD_DIR = build
BUILD_TESTS_DIR = $(BUILD_DIR)/tests
SRC_DIR = src
TESTS_DIR = tests
INC_DIR = include
PUB_LIB_DIR = /usr/lib
PUB_INC_DIR = /usr/include/pb/afxdp
# LibXDP and LibBPF directories.
XDP_TOOLS_DIR = modules/xdp-tools
LIBXDP_DIR = $(XDP_TOOLS_DIR)/lib/libxdp
# LibXDP shared object.
LIBXDP_OBJ = $(LIBXDP_DIR)/libxdp.so
# Main library.
AFXDP_OBJ = afxdp.o
SHARED_OBJ = libpbafxdp.so
# Includes.
INCS = -I $(INC_DIR) -I /usr/include -I $(SRC_DIR)/common
LD_FLAGS = -lelf -lz
ifeq ($(STATIC), 1)
OBJS = $(LIBXDP_OBJ)
FLAGS = -D__STATIC__
else
INCS += -I $(XDP_TOOLS_DIR)/headers
LD_FLAGS += -lbpf -lxdp
endif
all: libpbafxdp
afxdp:
$(CC) $(INCS) -fPIC -O2 -g -c -o $(BUILD_DIR)/$(AFXDP_OBJ) $(SRC_DIR)/afxdp.c
libpbafxdp: afxdp
$(CC) $(INCS) $(LD_FLAGS) $(FLAGS) -fPIC -O2 -g -shared -o $(BUILD_DIR)/$(SHARED_OBJ) $(BUILD_DIR)/$(AFXDP_OBJ) $(OBJS) $(SRC_DIR)/main.c
tests:
$(CC) $(INCS) $(LD_FLAGS) -lpbafxdp -O2 -g -o $(BUILD_TESTS_DIR)/tcp_syn_test $(TESTS_DIR)/tcp_syn_test.c
install:
mkdir -p $(PUB_INC_DIR)
cp -f $(BUILD_DIR)/$(SHARED_OBJ) $(PUB_LIB_DIR)
cp -f $(INC_DIR)/api.h $(PUB_INC_DIR)
clean:
find $(BUILD_DIR) -type f ! -name ".*" -exec rm -f {} +
find $(BUILD_TESTS_DIR) -type f ! -name ".*" -exec rm -f {} +
# LibXDP chain. We need to install objects here since our program relies on installed object files and such.
libxdp:
$(MAKE) -C $(XDP_TOOLS_DIR) libxdp
libxdp_install:
$(MAKE) -C $(LIBBPF_SRC) install
$(MAKE) -C $(LIBXDP_DIR) install
libxdp_clean:
$(MAKE) -C $(XDP_TOOLS_DIR) clean
$(MAKE) -C $(LIBBPF_SRC) clean
.PHONY: tests