Do not create (empty) latency loss file if disabled
[samplevnf.git] / VNFs / DPPD-PROX / Makefile
1 ##
2 ## Copyright (c) 2010-2019 Intel Corporation
3 ##
4 ## Licensed under the Apache License, Version 2.0 (the "License");
5 ## you may not use this file except in compliance with the License.
6 ## You may obtain a copy of the License at
7 ##
8 ##     http://www.apache.org/licenses/LICENSE-2.0
9 ##
10 ## Unless required by applicable law or agreed to in writing, software
11 ## distributed under the License is distributed on an "AS IS" BASIS,
12 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ## See the License for the specific language governing permissions and
14 ## limitations under the License.
15 ##
16
17 ifeq ($(RTE_SDK),)
18 define err_msg
19
20 Please define RTE_SDK environment variable.
21 If DPDK was built with Meson, please use meson to build Prox too.
22 ***
23 endef
24 $(error $(err_msg))
25 endif
26
27 # Default target, can be overriden by command line or environment
28 RTE_TARGET ?= x86_64-native-linuxapp-gcc
29
30 ifeq ($(wildcard $(RTE_SDK)/$(RTE_TARGET)/.),)
31 define err_msg
32
33 Could not find build target: $(RTE_TARGET)
34 Perhaps DPDK was built using meson?
35 ***
36 endef
37 $(error $(err_msg))
38 endif
39
40 rte_version_h := $(RTE_SDK)/$(RTE_TARGET)/include/rte_version.h
41 rte_config_h := $(RTE_SDK)/$(RTE_TARGET)/include/rte_config.h
42 rte_ver_part = $(shell sed -n -e 's/^\#define\s*$1\s*\(.*\)$$/\1/p' $(rte_version_h))
43 rte_config_part = $(shell sed -n -e 's/^\#define\s*$1\s*\(.*\)$$/\1/p' $(rte_config_h))
44 rte_ver_eval = $(shell printf '%u' $$(printf '0x%02x%02x%02x%02x' $1 $2 $3 $4))
45 rte_ver_MMLR = $(call rte_ver_eval,$(call \
46         rte_ver_part,RTE_VER_MAJOR),$(call \
47         rte_ver_part,RTE_VER_MINOR),$(call \
48         rte_ver_part,RTE_VER_PATCH_LEVEL),$(call \
49         rte_ver_part,RTE_VER_PATCH_RELEASE))
50 rte_version_YMMR = $(call rte_ver_eval,$(call \
51         rte_ver_part,RTE_VER_YEAR),$(call \
52         rte_ver_part,RTE_VER_MONTH),$(call \
53         rte_ver_part,RTE_VER_MINOR),$(call \
54         rte_ver_part,RTE_VER_RELEASE))
55 rte_config_YMMR = $(call rte_ver_eval,$(call \
56         rte_config_part,RTE_VER_YEAR),$(call \
57         rte_config_part,RTE_VER_MONTH),$(call \
58         rte_config_part,RTE_VER_MINOR),$(call \
59         rte_config_part,RTE_VER_RELEASE))
60 rte_ver_YMMR = $(if $(shell test $(rte_config_YMMR) -gt 0 && echo 'y'),$(rte_config_YMMR),$(rte_version_YMMR))
61 rte_ver_dpdk := $(if $(call rte_ver_part,RTE_VER_MAJOR),$(rte_ver_MMLR),$(rte_ver_YMMR))
62 rte_ver_comp = $(shell test $(rte_ver_dpdk) $5 $(call rte_ver_eval,$1,$2,$3,$4) && echo 'y')
63 rte_ver_EQ = $(call rte_ver_comp,$1,$2,$3,$4,-eq)
64 rte_ver_NE = $(call rte_ver_comp,$1,$2,$3,$4,-ne)
65 rte_ver_GT = $(call rte_ver_comp,$1,$2,$3,$4,-gt)
66 rte_ver_LT = $(call rte_ver_comp,$1,$2,$3,$4,-lt)
67 rte_ver_GE = $(call rte_ver_comp,$1,$2,$3,$4,-ge)
68 rte_ver_LE = $(call rte_ver_comp,$1,$2,$3,$4,-le)
69
70 include $(RTE_SDK)/mk/rte.vars.mk
71
72 # binary name
73 APP = prox
74 CFLAGS += -DPROGRAM_NAME=\"$(APP)\"
75
76 CFLAGS += -O2 -g
77 CFLAGS += -fno-stack-protector -Wno-deprecated-declarations
78
79 ifeq ($(BNG_QINQ),)
80 CFLAGS += -DUSE_QINQ
81 else ifeq ($(BNG_QINQ),y)
82 CFLAGS += -DUSE_QINQ
83 endif
84
85 ifeq ($(MPLS_ROUTING),)
86 CFLAGS += -DMPLS_ROUTING
87 else ifeq ($(MPLS_ROUTING),y)
88 CFLAGS += -DMPLS_ROUTING
89 endif
90
91 LD_LUA  = $(shell pkg-config --silence-errors --libs-only-l lua)
92 CFLAGS += $(shell pkg-config --silence-errors --cflags lua)
93 ifeq ($(LD_LUA),)
94 LD_LUA  = $(shell pkg-config --silence-errors --libs-only-l lua5.2)
95 CFLAGS += $(shell pkg-config --silence-errors --cflags lua5.2)
96 ifeq ($(LD_LUA),)
97 LD_LUA  = $(shell pkg-config --silence-errors --libs-only-l lua5.3)
98 CFLAGS += $(shell pkg-config --silence-errors --cflags lua5.3)
99 ifeq ($(LD_LUA),)
100 LD_LUA =-llua
101 endif
102 endif
103 endif
104
105 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
106 LDLIBS += -lrte_pmd_ring -lrte_pmd_null -lrte_pmd_ixgbe -lrte_pmd_i40e  -lrte_pmd_e1000  -lrte_pmd_virtio -lrte_pmd_vmxnet3_uio
107 endif
108
109 LD_TINFO = $(shell pkg-config --silence-errors --libs-only-l tinfo)
110 LDFLAGS += -lm -lpcap $(LD_TINFO) $(LD_LUA)
111 LDFLAGS += -lncurses -lncursesw -ledit
112
113 PROX_STATS ?= y
114 ifeq ($(PROX_STATS),y)
115 CFLAGS += -DPROX_STATS
116 endif
117
118 ifeq ($(DPI_STATS),y)
119 CFLAGS += -DDPI_STATS
120 endif
121
122 ifeq ($(HW_DIRECT_STATS),y)
123 CFLAGS += -DPROX_HW_DIRECT_STATS
124 endif
125
126 ifeq ($(dbg),y)
127 EXTRA_CFLAGS += -ggdb
128 endif
129
130 ifeq ($(log),)
131 CFLAGS += -DPROX_MAX_LOG_LVL=2
132 else
133 CFLAGS += -DPROX_MAX_LOG_LVL=$(log)
134 endif
135
136 # When ipv4 packet is de-encalpusled from ipv6 packet, genaerate IP checksum.
137 ifeq ($(GEN_DECAP_IPV6_TO_IPV4_CKSUM),y)
138 CFLAGS += -DGEN_DECAP_IPV6_TO_IPV4_CKSUM
139 endif
140
141 # override any use-case/enviroment specific choices regarding crc and
142 # always use the sw implementation
143 ifeq ($(crc),soft)
144 CFLAGS += -DSOFT_CRC
145 endif
146
147 CFLAGS += -DPROX_PREFETCH_OFFSET=2
148 #CFLAGS += -DBRAS_RX_BULK
149 #CFLAGS += -DASSERT
150 #CFLAGS += -DENABLE_EXTRA_USER_STATISTICS
151 CFLAGS += -DLATENCY_PER_PACKET
152 CFLAGS += -DLATENCY_HISTOGRAM
153 CFLAGS += -DGRE_TP
154 CFLAGS += -std=gnu99
155 CFLAGS += -D_GNU_SOURCE                # for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
156 CFLAGS += $(WERROR_FLAGS)
157 CFLAGS += -Wno-unused
158 CFLAGS += -Wno-unused-parameter
159 CFLAGS += -Wno-unused-result
160
161 # all source are stored in SRCS-y
162
163 SRCS-y := task_init.c
164
165 SRCS-y += handle_aggregator.c
166 SRCS-y += handle_nop.c
167 SRCS-y += handle_irq.c
168 SRCS-y += handle_arp.c
169 SRCS-y += handle_impair.c
170 SRCS-y += handle_lat.c
171 SRCS-y += handle_qos.c
172 SRCS-y += handle_qinq_decap4.c
173 SRCS-y += handle_routing.c
174 SRCS-y += handle_untag.c
175 SRCS-y += handle_mplstag.c
176 SRCS-y += handle_qinq_decap6.c
177
178 # support for GRE encap/decap dropped in latest DPDK versions
179 SRCS-$(call rte_ver_LT,2,1,0,0) += handle_gre_decap_encap.c
180
181 SRCS-y += rw_reg.c
182 SRCS-y += handle_lb_qinq.c
183 SRCS-y += handle_lb_pos.c
184 SRCS-y += handle_lb_net.c
185 SRCS-y += handle_qinq_encap4.c
186 SRCS-y += handle_qinq_encap6.c
187 SRCS-y += handle_classify.c
188 SRCS-y += handle_l2fwd.c
189 SRCS-y += handle_swap.c
190 SRCS-y += handle_police.c
191 SRCS-y += handle_acl.c
192 SRCS-y += handle_gen.c
193 SRCS-y += handle_master.c
194 SRCS-y += packet_utils.c
195 SRCS-y += handle_mirror.c
196 SRCS-y += handle_genl4.c
197 SRCS-y += handle_ipv6_tunnel.c
198 SRCS-y += handle_read.c
199 SRCS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += handle_esp.c
200 ifneq ($(CONFIG_RTE_LIBRTE_PMD_AESNI_MB),y)
201 ifeq ($(FIRST_PROX_MAKE),)
202 $(warning "Building w/o IPSEC support")
203 endif
204 endif
205 SRCS-y += handle_cgnat.c
206 SRCS-y += handle_nat.c
207 SRCS-y += handle_dump.c
208 SRCS-y += handle_tsc.c
209 SRCS-y += handle_fm.c
210 SRCS-$(call rte_ver_GE,1,8,0,16) += handle_nsh.c
211 SRCS-y += handle_lb_5tuple.c
212 SRCS-y += handle_blockudp.c
213 SRCS-y += toeplitz.c
214 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += handle_pf_acl.c
215
216 SRCS-y += thread_nop.c
217 SRCS-y += thread_generic.c
218 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread_pipeline.c
219
220 SRCS-y += prox_args.c prox_cfg.c prox_cksum.c prox_port_cfg.c
221
222 SRCS-y += cfgfile.c clock.c commands.c cqm.c msr.c defaults.c
223 SRCS-y += display.c display_latency.c display_latency_distr.c display_mempools.c
224 SRCS-y += display_ports.c display_rings.c display_priority.c display_pkt_len.c display_l4gen.c display_tasks.c display_irq.c
225 SRCS-y += log.c hash_utils.c main.c parse_utils.c file_utils.c
226 SRCS-y += run.c input_conn.c input_curses.c
227 SRCS-y += rx_pkt.c lconf.c tx_pkt.c expire_cpe.c ip_subnet.c
228 SRCS-y += stats_port.c stats_mempool.c stats_ring.c stats_l4gen.c
229 SRCS-y += stats_latency.c stats_global.c stats_core.c stats_task.c stats_prio.c stats_irq.c
230 SRCS-y += cmd_parser.c input.c prox_shared.c prox_lua_types.c
231 SRCS-y += genl4_bundle.c heap.c genl4_stream_tcp.c genl4_stream_udp.c cdf.c
232 SRCS-y += stats.c stats_cons_log.c stats_cons_cli.c stats_parser.c hash_set.c prox_lua.c prox_malloc.c prox_ipv6.c prox_compat.c
233 SRCS-y += git_version.c
234
235 GIT_VERSION := "$(shell git describe --abbrev=8 --dirty --always)"
236
237 ifeq ($(FIRST_PROX_MAKE),)
238 MAKEFLAGS += --no-print-directory
239 FIRST_PROX_MAKE = 1
240 export FIRST_PROX_MAKE
241 all:    libedit_autoconf.h git_version.c
242         @./helper-scripts/trailing.sh
243         @$(MAKE) $@
244 clean:
245         $(Q) $(RM) -- 'libedit_autoconf.h'
246         @$(MAKE) $@
247 %::
248         @$(MAKE) $@
249
250 ifeq ($(call rte_ver_LT,17,2,0,0),y)
251 AUTO-CONFIG-SCRIPT = $(RTE_SDK)/scripts/auto-config-h.sh
252 else
253 AUTO-CONFIG-SCRIPT = $(RTE_SDK)/buildtools/auto-config-h.sh
254 endif
255
256 # DPDK CFLAGS prevents auto-conf program to properly compile
257 export CFLAGS=
258 # if el_rfunc_t exists, define HAVE_LIBEDIT_EL_RFUNC_T so that PROX knows it can use it
259 libedit_autoconf.h: $(AUTO-CONFIG-SCRIPT)
260         $(Q) $(RM) -- '$@'
261         $(Q) sh -- '$(AUTO-CONFIG-SCRIPT)' '$@' \
262                 HAVE_LIBEDIT_EL_RFUNC_T \
263                 histedit.h \
264                 type 'el_rfunc_t' \
265                 > /dev/null
266 # auto-conf adds empty line at the end of the file, considered as error by trailing.sh script
267         $(Q) sed -i '$$ d' '$@'
268
269 git_version.c: force
270         @echo 'const char *git_version=$(GIT_VERSION);' | cmp -s - $@ || echo 'const char *git_version=$(GIT_VERSION);' > $@
271         @echo $@
272 force:
273         
274 else
275 include $(RTE_SDK)/mk/rte.extapp.mk
276 endif