Do not create (empty) latency loss file if disabled
[samplevnf.git] / VNFs / DPPD-PROX / meson.build
1 ##
2 ## Copyright (c) 2021 Heinrich Kuhn <heinrich.kuhn@corigine.com>
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 project('dppd-prox', 'C',
18         version:
19         run_command(['git', 'describe',
20                      '--abbrev=8', '--dirty', '--always']).stdout().strip(),
21         license: 'Apache',
22         default_options: ['buildtype=release', 'c_std=gnu99'],
23         meson_version: '>= 0.47'
24 )
25
26 cc = meson.get_compiler('c')
27
28 # Configure options for prox
29 if get_option('bng_qinq').enabled()
30         add_project_arguments('-DUSE_QINQ', language: 'c')
31 endif
32
33 if get_option('mpls_routing').enabled()
34         add_project_arguments('-DMPLS_ROUTING',  language: 'c')
35 endif
36
37 if get_option('prox_stats').enabled()
38         add_project_arguments('-DPROX_STATS',  language: 'c')
39 endif
40
41 if get_option('hw_direct_stats').enabled()
42         add_project_arguments('-DPROX_HW_DIRECT_STATS',  language: 'c')
43 endif
44
45 if get_option('dbg')
46         add_project_arguments('-ggdb',  language: 'c')
47 endif
48
49 if get_option('log')
50         add_project_arguments('-DPROX_MAX_LOG_LVL=2',  language: 'c')
51 endif
52
53 if get_option('gen_decap_ipv6_to_ipv4_cksum').enabled()
54         add_project_arguments('-DGEN_DECAP_IPV6_TO_IPV4_CKSUM',  language: 'c')
55 endif
56
57 if get_option('crc') == 'soft'
58         add_project_arguments('-DSOFT_CRC',  language: 'c')
59 endif
60
61 cflags = [
62         '-DPROGRAM_NAME="prox"',
63         '-fno-stack-protector',
64         '-DPROX_PREFETCH_OFFSET=2',
65         '-DLATENCY_PER_PACKET',
66         '-DLATENCY_HISTOGRAM',
67         '-DGRE_TP',
68         '-D_GNU_SOURCE']        # for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
69
70 # Add configured cflags to arguments
71 foreach arg: cflags
72         add_project_arguments(arg, language: 'c')
73 endforeach
74
75 # enable warning flags if they are supported by the compiler
76 warning_flags = [
77         '-Wno-unused',
78         '-Wno-unused-parameter',
79         '-Wno-unused-result',
80         '-Wno-deprecated-declarations']
81
82 foreach arg: warning_flags
83         if cc.has_argument(arg)
84                 add_project_arguments(arg, language: 'c')
85         endif
86 endforeach
87
88 # Attempt to find a suitable lua and add to deps
89 lua_versions = ['lua', 'lua5.2', 'lua5.3']
90 foreach i:lua_versions
91         lua_dep = dependency(i, required: false)
92         if not lua_dep.found()
93         lua_dep = cc.find_library(i, required: false)
94         endif
95         if lua_dep.found()
96         break
97         endif
98 endforeach
99 if not lua_dep.found()
100         error('Suitable lua version not found')
101 endif
102
103 has_sym_args = [
104         [ 'HAVE_LIBEDIT_EL_RFUNC_T', 'histedit.h',
105         'el_rfunc_t' ],
106 ]
107 config = configuration_data()
108 foreach arg:has_sym_args
109         config.set(arg[0], cc.has_header_symbol(arg[1], arg[2]))
110 endforeach
111 configure_file(output : 'libedit_autoconf.h', configuration : config)
112
113 # All other dependencies
114 dpdk_dep = dependency('libdpdk', required: true)
115 tinfo_dep = dependency('tinfo', required: false)
116 threads_dep = dependency('threads', required: true)
117 pcap_dep = dependency('pcap', required: true)
118 ncurses_dep = dependency('ncurses', required: true)
119 ncursesw_dep = dependency('ncursesw', required: true)
120 libedit_dep = dependency('libedit', required: true)
121 math_dep = cc.find_library('m', required : false)
122
123 deps = [dpdk_dep,
124         tinfo_dep,
125         threads_dep,
126         pcap_dep,
127         ncurses_dep,
128         ncursesw_dep,
129         libedit_dep,
130         math_dep,
131         lua_dep]
132
133 # Grab the DPDK version here "manually" as it is not available in the dpdk_dep
134 # object
135 dpdk_version = run_command('pkg-config', '--modversion', 'libdpdk').stdout()
136
137 # Explicitly add these to the dependency list
138 deps += [cc.find_library('rte_bus_vdev', required: true)]
139
140 if dpdk_version.version_compare('<20.11.0')
141 deps += [cc.find_library('rte_pmd_ring', required: true)]
142 else
143 deps += [cc.find_library('rte_net_ring', required: true)]
144 endif
145
146 sources = files(
147         'task_init.c', 'handle_aggregator.c', 'handle_nop.c', 'handle_irq.c',
148         'handle_arp.c', 'handle_impair.c', 'handle_lat.c', 'handle_qos.c',
149         'handle_qinq_decap4.c', 'handle_routing.c', 'handle_untag.c',
150         'handle_mplstag.c', 'handle_qinq_decap6.c', 'rw_reg.c',
151         'handle_lb_qinq.c', 'handle_lb_pos.c', 'handle_lb_net.c',
152         'handle_qinq_encap4.c', 'handle_qinq_encap6.c', 'handle_classify.c',
153         'handle_l2fwd.c', 'handle_swap.c', 'handle_police.c', 'handle_acl.c',
154         'handle_gen.c', 'handle_master.c', 'packet_utils.c', 'handle_mirror.c',
155         'handle_genl4.c', 'handle_ipv6_tunnel.c', 'handle_read.c',
156         'handle_cgnat.c', 'handle_nat.c', 'handle_dump.c', 'handle_tsc.c',
157         'handle_fm.c', 'handle_lb_5tuple.c', 'handle_blockudp.c', 'toeplitz.c',
158         'thread_nop.c', 'thread_generic.c', 'prox_args.c', 'prox_cfg.c',
159         'prox_cksum.c', 'prox_port_cfg.c', 'cfgfile.c', 'clock.c',
160         'commands.c', 'cqm.c', 'msr.c', 'defaults.c', 'display.c',
161         'display_latency.c', 'display_latency_distr.c', 'display_mempools.c',
162         'display_ports.c', 'display_rings.c', 'display_priority.c',
163         'display_pkt_len.c', 'display_l4gen.c', 'display_tasks.c',
164         'display_irq.c', 'log.c', 'hash_utils.c', 'main.c', 'parse_utils.c',
165         'file_utils.c', 'run.c', 'input_conn.c', 'input_curses.c', 'rx_pkt.c',
166         'lconf.c', 'tx_pkt.c', 'expire_cpe.c', 'ip_subnet.c', 'stats_port.c',
167         'stats_mempool.c', 'stats_ring.c', 'stats_l4gen.c', 'stats_latency.c',
168         'stats_global.c', 'stats_core.c', 'stats_task.c', 'stats_prio.c',
169         'stats_irq.c', 'cmd_parser.c', 'input.c', 'prox_shared.c',
170         'prox_lua_types.c', 'genl4_bundle.c', 'heap.c', 'genl4_stream_tcp.c',
171         'genl4_stream_udp.c', 'cdf.c', 'stats.c', 'stats_cons_log.c',
172         'stats_cons_cli.c', 'stats_parser.c', 'hash_set.c', 'prox_lua.c',
173         'prox_malloc.c', 'prox_ipv6.c', 'prox_compat.c', 'handle_nsh.c')
174
175 # Include a couple of source files depending on DPDK support
176 if cc.find_library('rte_pmd_aesni', required: false).found()
177         sources += files('handle_esp.c')
178 else
179         warning('Building w/o IPSEC support')
180 endif
181
182 if cc.find_library('rte_pipeline', required: false).found()
183         sources += files('handle_pf_acl.c', 'thread_pipeline.c')
184 endif
185
186 # Generate the git_version.c file and add to sources
187 git_version = configuration_data()
188 git_version.set('GIT_VERSION', '@0@'.format(meson.project_version()))
189 git_version_c = configure_file(input: 'git_version.c.in',
190         output: 'git_version.c',
191         configuration: git_version)
192
193 git_version_file = join_paths(meson.current_build_dir(), 'git_version.c')
194 sources += files(git_version_file)
195
196 executable('prox',
197         sources,
198         c_args: cflags,
199         dependencies: deps,
200         install: true)