-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
130 lines (109 loc) · 3.93 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
ARCH ?= x86
TOPDIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
KSRC ?= $(TOPDIR)/build_sources/linux
LLVM ?=
LLC=${LLVM}llc
CLANG=${LLVM}clang
# If set to 1 then timestemps before lwip stack and after
# will be printed.
LWIP_PRINT_TS=0
ifeq ($(ARCH),arm)
export HOST=arm-linux-gnueabihf
export CC=arm-linux-gnueabihf-gcc
export LD=arm-linux-gnueabihf-ld
export CROSS_COMPILE=arm-linux-gnueabihf-
endif
CFLAGS = -Wno-unused-value -Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member -Wno-tautological-compare \
-Wno-unknown-warning-option -O2 -Wall
LDFLAGS = -lbpf -lelf -pthread
all: xdpsock lwip open62541 open62541-demos socket_wrapper iperf
.PHONY: zlib
zlib:
cd build_sources/zlib && \
./configure && \
make install prefix=`pwd`/../../build_install
.PHONY: elfutils
elfutils:
cd build_sources/elfutils && \
./configure --host=${HOST} --prefix=`pwd`/../../build_install \
CFLAGS="-I`pwd`/../../build_install/include -Wno-implicit-fallthrough -Wno-error -O2" \
LDFLAGS="-L`pwd`/../../build_install/lib -lz" && \
make install
.PHONY: libbpf
libbpf: zlib elfutils
cd build_sources/linux && \
make multi_v7_defconfig && \
make -j 4 > /dev/null && \
cd tools/lib/bpf && \
make CFLAGS="-I$(TOPDIR)/build_install/include" LDFLAGS="-L$(TOPDIR)/build_install/lib" && \
cp libbpf.so ../../../../../build_install/lib/
.PHONY: iperf
iperf: lwip
cd build_sources/iperf-xdp && \
./configure --host=${HOST} CFLAGS="-I`pwd`/../../build_sources/lwip/src/include \
-I`pwd`/../../build_sources/lwip/contrib/ports/unix/lib \
-I`pwd`/../../build_sources/lwip/contrib/ports/unix/port/include \
-I`pwd`/../../lwip \
-I$(TOPDIR)/build_install/include -L$(TOPDIR)/build_install/lib -lbpf -lelf -lz -lipxdp" \
LDFLAGS="-L`pwd`/../../lwip -lipxdp" \
--prefix=`pwd`/../../build_install --without-openssl && \
make && \
make install
.PHONY: socket_wrapper
socket_wrapper: open62541
cd socket_wrapper && \
LWIP_SRC=../build_sources/lwip/src \
IPXDP=../lwip \
make
.PHONY: xdpsock
xdpsock:
$(CC) xdpsock_user.c -I./include -I$(KSRC)/tools/lib/ \
-I$(KSRC)/tools/testing/selftests/bpf \
-I$(KSRC)/tools/testing/selftests/bpf/include \
-I$(KSRC)/tools/include -I. -I$(KSRC)/tools/lib/bpf \
-I$(TOPDIR)/build_install/include -L$(TOPDIR)/build_install/lib \
-I$(KSRC)/include/uapi -Wl,-Bstatic -L$(KSRC)/tools/lib/bpf/ \
-Wl,-Bdynamic $(LDFLAGS) -lz -o xdpsock -Wall
${CLANG} -nostdinc \
-I$(KSRC)/arch/$(ARCH)/include -I$(KSRC)/arch/$(ARCH)/include/generated \
-I$(KSRC)/arch/$(ARCH)/include/generated/uapi -I$(KSRC)/include/uapi \
-I$(KSRC)/samples/bpf \
-I$(KSRC)/include -I$(KSRC)/arch/$(ARCH)/include/uapi \
-I$(KSRC)/tools/testing/selftests/bpf/ \
-D__KERNEL__ -D__BPF_TRACING__ \
$(CFLAGS) \
-O2 -emit-llvm -c xdpsock_kern.c
${LLC} -march=bpf -filetype=obj xdpsock_kern.bc -o xdpsock_kern.o
.PHONY: lwip
lwip:
cd lwip && \
ARCH=$(ARCH) KSRC=$(KSRC) LWIPDIR=../build_sources/lwip/src \
EXT_FLAGS="-I$(TOPDIR)/build_install/include -L$(TOPDIR)/build_install/lib -DLWIP_PRINT_TS=$(LWIP_PRINT_TS)"\
make
.PHONY: open62541
open62541:
cd build_sources/open62541 && mkdir -p build && \
sed -i 's/set(LWIP_SRC.*/set\(LWIP_SRC "..\/..\/..\/build_sources\/lwip\/src")/g' CMakeLists.txt && \
cd build && cmake -DCMAKE_INSTALL_PREFIX=../../../build_install ../ && \
make && \
make install
open62541-demos: open62541
cd build_sources/open62541demos/open62541temp && \
LWIP_SRC=../../../build_sources/lwip/src \
IPXDP=../../../lwip \
OPCUA=../../../build_install \
OPCUA_SRC=../../../build_sources/open62541 \
CFLAGS="-I$(TOPDIR)/build_install/include -L$(TOPDIR)/build_install/lib -lbpf -lelf -lz -lipxdp" \
make
.PHONY: install
install: all
cp ./lwip/libipxdp.so ./build_install/lib/
cp xdpsock_kern.o ./build_install/bin/lwip_af_xdp_kern.o
.PHONY: clean
clean:
rm -rf xdpsock
rm -rf xdpsock_kern.o
rm -rf xdpsock_kern.bc