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