forked from F-Stack/f-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
675 lines (582 loc) · 13.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
#
# Copyright (c) 2013 Patrick Kelsey. All rights reserved.
# Copyright (C) 2017 THL A29 Limited, a Tencent company.
# All rights reserved.
#
# Derived in part from libuinet's Makefile.
#
# Derived from FreeBSD auto-generated kernel Makefile and
# machine-specific Makefile templates
#
TOPDIR?=${CURDIR}/..
S=${TOPDIR}/freebsd
MACHINE_INCLUDES_ROOT:=${CURDIR}/machine_include
OVERRIDE_INCLUDES_ROOT:=${CURDIR}/include
X86_INCLUDES=0
PREFIX=/usr/local
PREFIX_LIB=${PREFIX}/lib
PREFIX_INCLUDE=/usr/local/include
PREFIX_BIN=/usr/local/bin
F-STACK_CONF=/etc/f-stack.conf
F-STACK_VERSION=1.20
HOST_OS:=$(shell uname -s)
#DEBUG=-O0 -gdwarf-2 -g3 -Wno-format-truncation
FF_KNI=1
#FF_NETGRAPH=1
#FF_IPFW=1
#FF_USE_PAGE_ARRAY=1
FF_INET6=1
include ${TOPDIR}/mk/kern.pre.mk
ifeq ($(FF_DPDK),)
ifeq (${MACHINE_CPUARCH},aarch64)
FF_DPDK=${TOPDIR}/dpdk/build
else
FF_DPDK=${TOPDIR}/dpdk/x86_64-native-linuxapp-gcc
endif
endif
ifdef RTE_SDK
ifeq (${MACHINE_CPUARCH},aarch64)
FF_DPDK=${RTE_SDK}/build
else
FF_DPDK=${RTE_SDK}/x86_64-native-linuxapp-gcc
endif
endif
DPDK_CFLAGS= -Wall -Wno-deprecated-declarations -Werror -include ${FF_DPDK}/include/rte_config.h
DPDK_CFLAGS+= -march=native -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3
DPDK_CFLAGS+= -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2
DPDK_CFLAGS+= -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2
DPDK_CFLAGS+= -I${FF_DPDK}/include
KERNPREINCLUDES:= ${INCLUDES}
INCLUDES= -I${OVERRIDE_INCLUDES_ROOT} ${KERNPREINCLUDES}
INCLUDES+= -I./machine_include
INCLUDES+= -I./opt
# Include search path for files that only include host OS headers
HOST_INCLUDES= -I.
ifndef DEBUG
HOST_CFLAGS = -O2 -frename-registers -funswitch-loops -fweb -Wno-format-truncation
else
HOST_CFLAGS = ${DEBUG}
endif
ifdef FF_KNI
HOST_CFLAGS+= -DFF_KNI
endif
HOST_CFLAGS+= ${DPDK_CFLAGS}
HOST_CFLAGS+= ${CONF_CFLAGS}
ifdef FF_NETGRAPH
HOST_CFLAGS+= -DFF_NETGRAPH
endif
ifdef FF_IPFW
HOST_CFLAGS+= -DFF_IPFW
endif
ifdef FF_USE_PAGE_ARRAY
HOST_CFLAGS+= -DFF_USE_PAGE_ARRAY
endif
ifdef FF_INET6
HOST_CFLAGS+= -DINET6
CFLAGS+= -DINET6
endif
HOST_C= ${CC} -c $(HOST_CFLAGS) ${HOST_INCLUDES} ${WERROR} ${PROF} $<
ifneq ($(filter amd64 i386,${MACHINE_CPUARCH}),)
X86_INCLUDES=1
endif
#
# Distilled from FreeBSD src/sys/conf/Makefile.amd64
#
ifeq (${MACHINE_CPUARCH},amd64)
endif
#
# Distilled from FreeBSD src/sys/conf/Makefile.arm
#
ifeq (${MACHINE_CPUARCH},arm)
ifneq (${COMPILER_TYPE},clang)
CFLAGS += -mno-thumb-interwork
endif
endif
#
# fix the MACHINE_CPUARCH to match the FreeBSD directory name
#
ifeq (${MACHINE_CPUARCH},aarch64)
MACHINE_CPUARCH=arm64
endif
#
# Distilled from FreeBSD src/sys/conf/Makefile.i386
#
ifeq (${MACHINE_CPUARCH},i386)
MACHINE=i386
endif
#
# Distilled from FreeBSD src/sys/conf/Makefile.mips
#
ifeq (${MACHINE_CPUARCH},mips)
# We default to the MIPS32 ISA, if none specified in the
# kernel configuration file.
ARCH_FLAGS?=-march=mips32
HACK_EXTRA_FLAGS=-shared
CFLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)
HACK_EXTRA_FLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)
endif
CFLAGS+= -DFSTACK
# add for LVS tcp option toa, disabled by default
# CFLAGS+= -DLVS_TCPOPT_TOA
VPATH+= $S/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
VPATH+= $S/kern
VPATH+= $S/crypto
VPATH+= $S/crypto/aesni
VPATH+= $S/crypto/blowfish
VPATH+= $S/crypto/camellia
VPATH+= $S/crypto/des
VPATH+= $S/crypto/rijndael
VPATH+= $S/crypto/sha2
VPATH+= $S/crypto/siphash
VPATH+= $S/net
ifdef FF_NETGRAPH
VPATH+= $S/netgraph
endif
VPATH+= $S/netinet
VPATH+= $S/netinet/libalias
VPATH+= $S/netinet/cc
ifdef FF_INET6
VPATH+= $S/netinet6
endif
VPATH+= $S/netipsec
ifdef FF_IPFW
VPATH+= $S/netpfil/ipfw
endif
VPATH+= $S/opencrypto
VPATH+= $S/vm
VPATH+= $S/libkern
FF_SRCS+= \
ff_compat.c \
ff_glue.c \
ff_freebsd_init.c \
ff_init_main.c \
ff_kern_condvar.c \
ff_kern_environment.c \
ff_kern_intr.c \
ff_kern_subr.c \
ff_kern_synch.c \
ff_kern_timeout.c \
ff_lock.c \
ff_syscall_wrapper.c \
ff_subr_prf.c \
ff_vfs_ops.c \
ff_veth.c \
ff_route.c
ifdef FF_NETGRAPH
FF_SRCS+= \
ff_ng_base.c \
ff_ngctl.c
endif
FF_HOST_SRCS+= \
ff_host_interface.c \
ff_config.c \
ff_ini_parser.c \
ff_dpdk_if.c \
ff_dpdk_pcap.c \
ff_epoll.c \
ff_init.c
ifdef FF_KNI
FF_HOST_SRCS+= \
ff_dpdk_kni.c
endif
ifdef FF_USE_PAGE_ARRAY
FF_HOST_SRCS+= \
ff_memory.c
endif
ifdef FF_IPSEC
CRYPTO_ASM_SRCS+= \
aesencdec_${MACHINE_CPUARCH}.S \
aeskeys_${MACHINE_CPUARCH}.S
CRYPTO_SRCS+= \
aesni.c \
aesni_wrap.c \
bf_ecb.c \
bf_enc.c \
bf_skey.c \
camellia.c \
camellia-api.c \
des_ecb.c \
des_enc.c \
des_setkey.c \
rijndael-alg-fst.c \
rijndael-api.c \
sha1.c \
sha256c.c \
sha512c.c \
siphash.c
else
CRYPTO_SRCS+= \
sha1.c \
siphash.c
endif
KERN_SRCS+= \
kern_descrip.c \
kern_event.c \
kern_fail.c \
kern_khelp.c \
kern_hhook.c \
kern_linker.c \
kern_mbuf.c \
kern_module.c \
kern_mtxpool.c \
kern_ntptime.c \
kern_osd.c \
kern_sysctl.c \
kern_tc.c \
kern_uuid.c \
link_elf.c \
md5c.c \
subr_capability.c \
subr_counter.c \
subr_eventhandler.c \
subr_kobj.c \
subr_lock.c \
subr_module.c \
subr_param.c \
subr_pcpu.c \
subr_sbuf.c \
subr_taskqueue.c \
subr_unit.c \
sys_capability.c \
sys_generic.c \
sys_socket.c \
uipc_accf.c \
uipc_mbuf.c \
uipc_mbuf2.c \
uipc_domain.c \
uipc_sockbuf.c \
uipc_socket.c \
uipc_syscalls.c
KERN_MHEADERS+= \
bus_if.m \
device_if.m \
linker_if.m
KERN_MSRCS+= \
linker_if.m
ifeq (${MACHINE_CPUARCH},arm64)
LIBKERN_SRCS+= \
bcd.c \
crc32.c \
inet_ntoa.c \
jenkins_hash.c \
strlcpy.c \
strnlen.c \
zlib.c \
fls.c \
flsl.c
else
LIBKERN_SRCS+= \
bcd.c \
crc32.c \
inet_ntoa.c \
jenkins_hash.c \
strlcpy.c \
strnlen.c \
zlib.c
endif
MACHINE_SRCS+= \
in_cksum.c
NET_SRCS+= \
bpf.c \
bridgestp.c \
if.c \
if_bridge.c \
if_clone.c \
if_dead.c \
if_ethersubr.c \
if_loop.c \
if_llatbl.c \
if_media.c \
if_spppfr.c \
if_spppsubr.c \
if_vlan.c \
if_vxlan.c \
in_fib.c \
in_gif.c \
ip_reass.c \
netisr.c \
pfil.c \
radix.c \
raw_cb.c \
raw_usrreq.c \
route.c \
rtsock.c \
slcompress.c
ifdef FF_NETGRAPH
NETGRAPH_SRCS += \
ng_async.c \
ng_atmllc.c \
ng_bridge.c \
ng_car.c \
ng_cisco.c \
ng_deflate.c \
ng_echo.c \
ng_eiface.c \
ng_etf.c \
ng_ether.c \
ng_ether_echo.c \
ng_frame_relay.c \
ng_gif.c \
ng_gif_demux.c \
ng_hole.c \
ng_hub.c \
ng_iface.c \
ng_ip_input.c \
ng_ipfw.c \
ng_ksocket.c \
ng_l2tp.c \
ng_lmi.c \
ng_nat.c \
ng_one2many.c \
ng_parse.c \
ng_patch.c \
ng_pipe.c \
ng_ppp.c \
ng_pppoe.c \
ng_pptpgre.c \
ng_pred1.c \
ng_rfc1490.c \
ng_sample.c \
ng_socket.c \
ng_source.c \
ng_split.c \
ng_sppp.c \
ng_tag.c \
ng_tcpmss.c \
ng_tee.c \
ng_UI.c \
ng_vjc.c \
ng_vlan.c
endif
NETINET_SRCS+= \
if_ether.c \
if_gif.c \
igmp.c \
in.c \
in_mcast.c \
in_pcb.c \
in_proto.c \
in_rmx.c \
ip_carp.c \
ip_divert.c \
ip_ecn.c \
ip_encap.c \
ip_fastfwd.c \
ip_icmp.c \
ip_id.c \
ip_input.c \
ip_mroute.c \
ip_options.c \
ip_output.c \
raw_ip.c \
tcp_debug.c \
tcp_fastopen.c \
tcp_hostcache.c \
tcp_input.c \
tcp_lro.c \
tcp_offload.c \
tcp_output.c \
tcp_reass.c \
tcp_sack.c \
tcp_subr.c \
tcp_syncache.c \
tcp_timer.c \
tcp_timewait.c \
tcp_usrreq.c \
udp_usrreq.c \
cc.c \
cc_newreno.c \
cc_htcp.c \
cc_cubic.c \
alias.c \
alias_db.c \
alias_mod.c \
alias_proxy.c \
alias_sctp.c \
alias_util.c
ifdef FF_INET6
NETINET6_SRCS+= \
dest6.c \
frag6.c \
icmp6.c \
in6.c \
in6_ifattach.c \
in6_mcast.c \
in6_pcb.c \
in6_pcbgroup.c \
in6_proto.c \
in6_rmx.c \
in6_src.c \
ip6_forward.c \
ip6_id.c \
ip6_input.c \
ip6_mroute.c \
ip6_output.c \
mld6.c \
nd6.c \
nd6_nbr.c \
nd6_rtr.c \
raw_ip6.c \
route6.c \
scope6.c \
send.c \
udp6_usrreq.c \
in6_cksum.c \
in6_fib.c \
in6_gif.c
#ip6_gre.c
#ip6_ipsec.c
#sctp6_usrreq.c
#in6_rss.c
endif
ifdef FF_IPFW
NETIPFW_SRCS+= \
ip_fw_dynamic.c \
ip_fw_eaction.c \
ip_fw_iface.c \
ip_fw_log.c \
ip_fw_nat.c \
ip_fw_pfil.c \
ip_fw_sockopt.c \
ip_fw_table.c \
ip_fw_table_algo.c \
ip_fw_table_value.c \
ip_fw2.c
endif
ifdef FF_IPSEC
NETINET_SRCS+= \
ip_ipsec.c
ifdef FF_INET6
NETINET6_SRCS+= \
ip6_ipsec.c
endif
endif
ifdef FF_IPSEC
NETIPSEC_SRCS+= \
ipsec.c \
ipsec_input.c \
ipsec_mbuf.c \
ipsec_output.c \
key.c \
key_debug.c \
keysock.c \
xform_ah.c \
xform_esp.c \
xform_ipcomp.c
endif
# only if TCP_SIGNTAURE is defined
#xform_tcp.c
ifdef FF_IPSEC
OPENCRYPTO_SRCS+= \
cast.c \
criov.c \
crypto.c \
cryptosoft.c \
deflate.c \
rmd160.c \
skipjack.c \
xform.c
endif
# cryptodev.c
OPENCRYPTO_MHEADERS= cryptodev_if.m
OPENCRYPTO_MSRCS= cryptodev_if.m
VM_SRCS+= \
uma_core.c
MHEADERS= $(patsubst %.m,%.h,${KERN_MHEADERS})
MHEADERS+= vnode_if.h vnode_if_newproto.h vnode_if_typedef.h
MHEADERS+= $(patsubst %.m,%.h,${OPENCRYPTO_MHEADERS})
MSRCS= $(patsubst %.m,%.c,${KERN_MSRCS})
MSRCS+= $(patsubst %.m,%.c,${OPENCRYPTO_MSRCS})
ASM_SRCS = ${CRYPTO_ASM_SRCS}
SRCS= ${FF_SRCS} ${CRYPTO_SRCS} ${KERN_SRCS} ${LIBKERN_SRCS} ${MACHINE_SRCS}
SRCS+= ${MSRCS} ${NET_SRCS} ${NETGRAPH_SRCS} ${NETINET_SRCS} ${NETINET6_SRCS}
SRCS+= ${NETIPSEC_SRCS} ${NETIPFW_SRCS} ${OPENCRYPTO_SRCS} ${VM_SRCS}
# If witness is enabled.
# SRCS+= ${KERN_WITNESS_SRCS}
# Extra FreeBSD kernel module srcs.
SRCS+= ${KMOD_SRCS}
HOST_SRCS = ${FF_HOST_SRCS}
ASM_OBJS+= $(patsubst %.S,%.o,${ASM_SRCS})
OBJS+= $(patsubst %.c,%.o,${SRCS})
HOST_OBJS+= $(patsubst %.c,%.o,${HOST_SRCS})
all: libfstack.a
#
# The library is built by first incrementally linking all the object
# to resolve internal references. Then, all symbols are made local.
# Then, only the symbols that are part of the API are made
# externally available.
#
libfstack.a: machine_includes ff_api.symlist ${MHEADERS} ${MSRCS} ${HOST_OBJS} ${ASM_OBJS} ${OBJS}
${LD} -d -r -o $*.ro ${ASM_OBJS} ${OBJS}
nm $*.ro | grep -v ' U ' | cut -d ' ' -f 3 > $*_localize_list.tmp
objcopy --localize-symbols=$*_localize_list.tmp $*.ro
rm $*_localize_list.tmp
objcopy --globalize-symbols=ff_api.symlist $*.ro
rm -f $@
ar -cqs $@ $*.ro ${HOST_OBJS}
rm -f $*.ro
${HOST_OBJS}: %.o: %.c
${HOST_C}
${ASM_OBJS}: %.o: %.S ${IMACROS_FILE}
${NORMAL_S}
${OBJS}: %.o: %.c ${IMACROS_FILE}
${NORMAL_C}
.SUFFIXES: .m
.m.c:
${AWK} -f $S/tools/makeobjops.awk $< -c
.m.h:
${AWK} -f $S/tools/makeobjops.awk $< -h
.PHONY: clean
clean:
rm -f libfstack.a
rm -f ${MHEADERS} ${MSRCS} ${HOST_OBJS} ${ASM_OBJS} ${OBJS} ${PROGRAM} ${IMACROS_FILE}
rm -rf ${MACHINE_INCLUDES_ROOT}
.PHONY: machine_includes
machine_includes:
@rm -rf ${MACHINE_INCLUDES_ROOT}
@mkdir -p ${MACHINE_INCLUDES_ROOT}/machine
@cp -r $S/${MACHINE_CPUARCH}/include/* ${MACHINE_INCLUDES_ROOT}/machine
@if [ "${X86_INCLUDES}" != "0" ]; then \
mkdir -p ${MACHINE_INCLUDES_ROOT}/x86; \
cp -r $S/x86/include/* ${MACHINE_INCLUDES_ROOT}/x86; \
fi
#
# Distilled from FreeBSD src/sys/conf/kern.post.mk
#
vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: $S/tools/vnode_if.awk \
$S/kern/vnode_if.src
vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -h
vnode_if_newproto.h:
${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -p
vnode_if_typedef.h:
${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -q
include ${TOPDIR}/mk/kern.mk
install:
rm -rf ${PREFIX_LIB}/libfstack.a.${F-STACK_VERSION}
rm -rf ${PREFIX_LIB}/libfstack.a
rm -rf ${PREFIX_INCLUDE}/ff_config.h
rm -rf ${PREFIX_INCLUDE}/ff_api.h
rm -rf ${PREFIX_INCLUDE}/ff_event.h
rm -rf ${PREFIX_INCLUDE}/ff_errno.h
rm -rf ${PREFIX_INCLUDE}/ff_epoll.h
rm -rf ${PREFIX_BIN}/ff_start
cp -f libfstack.a ${PREFIX_LIB}/libfstack.a.${F-STACK_VERSION}
ln -sf ${PREFIX_LIB}/libfstack.a.${F-STACK_VERSION} ${PREFIX_LIB}/libfstack.a
cp -f ff_config.h ${PREFIX_INCLUDE}/ff_config.h
cp -f ff_api.h ${PREFIX_INCLUDE}/ff_api.h
cp -f ff_event.h ${PREFIX_INCLUDE}/ff_event.h
cp -f ff_errno.h ${PREFIX_INCLUDE}/ff_errno.h
cp -f ff_epoll.h ${PREFIX_INCLUDE}/ff_epoll.h
cp -f ${TOPDIR}/start.sh ${PREFIX_BIN}/ff_start
test -f '${F-STACK_CONF}' || cp -f ${TOPDIR}/config.ini ${F-STACK_CONF}
uninstall:
rm -rf ${PREFIX_LIB}/libfstack.a.${F-STACK_VERSION}
rm -rf ${PREFIX_LIB}/libfstack.a
rm -rf ${PREFIX_INCLUDE}/ff_config.h
rm -rf ${PREFIX_INCLUDE}/ff_api.h
rm -rf ${PREFIX_INCLUDE}/ff_event.h
rm -rf ${PREFIX_INCLUDE}/ff_errno.h
rm -rf ${PREFIX_INCLUDE}/ff_epoll.h
rm -rf ${PREFIX_BIN}/ff_start
rm -rf ${F-STACK_CONF}