xref: /f-stack/dpdk/examples/meson.build (revision ebf5cedb)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2017-2019 Intel Corporation
3
4driver_libs = []
5if get_option('default_library') == 'static'
6	driver_libs = dpdk_drivers
7endif
8
9execinfo = cc.find_library('execinfo', required: false)
10
11# list of all example apps. Keep 1-3 per line, in alphabetical order.
12all_examples = [
13	'bbdev_app', 'bond',
14	'cmdline',
15	'distributor', 'ethtool',
16	'eventdev_pipeline',
17	'fips_validation', 'flow_classify',
18	'flow_filtering', 'helloworld',
19	'ioat',
20	'ip_fragmentation', 'ip_pipeline',
21	'ip_reassembly', 'ipsec-secgw',
22	'ipv4_multicast', 'kni',
23	'l2fwd', 'l2fwd-cat', 'l2fwd-event',
24	'l2fwd-crypto', 'l2fwd-jobstats',
25	'l2fwd-keepalive', 'l3fwd',
26	'l3fwd-acl', 'l3fwd-power',
27	'link_status_interrupt',
28	'multi_process/client_server_mp/mp_client',
29	'multi_process/client_server_mp/mp_server',
30	'multi_process/hotplug_mp',
31	'multi_process/simple_mp',
32	'multi_process/symmetric_mp',
33	'ntb', 'packet_ordering',
34	'performance-thread/l3fwd-thread',
35	'performance-thread/pthread_shim',
36	'ptpclient',
37	'qos_meter', 'qos_sched',
38	'rxtx_callbacks',
39	'server_node_efd/node',
40	'server_node_efd/server',
41	'service_cores',
42	'skeleton', 'tep_termination',
43	'timer', 'vdpa',
44	'vhost', 'vhost_crypto',
45	'vhost_blk', 'vm_power_manager',
46	'vm_power_manager/guest_cli',
47	'vmdq', 'vmdq_dcb',
48]
49# install all example code on install - irrespective of whether the example in
50# question is to be built as part of this build or not.
51foreach ex:all_examples
52	install_subdir(ex,
53			install_dir: get_option('datadir') + '/dpdk/examples',
54			exclude_files: 'meson.build')
55endforeach
56
57if get_option('examples') == ''
58	subdir_done()
59endif
60
61if get_option('examples').to_lower() == 'all'
62	examples = all_examples
63	allow_skips = true # don't flag an error if we can't build an app
64else
65	examples = get_option('examples').split(',')
66	allow_skips = false # error out if we can't build a requested app
67endif
68default_cflags = machine_args
69if cc.has_argument('-Wno-format-truncation')
70	default_cflags += '-Wno-format-truncation'
71endif
72
73foreach example: examples
74	name = example.split('/')[-1]
75	build = true
76	sources = []
77	allow_experimental_apis = false
78	cflags = default_cflags
79
80	ext_deps = [execinfo]
81	includes = [include_directories(example)]
82	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
83	if is_windows
84		deps = ['eal'] # only supported lib on Windows currently
85	endif
86	subdir(example)
87
88	if build
89		dep_objs = ext_deps
90		foreach d:deps
91			var_name = get_option('default_library') + '_rte_' + d
92			if not is_variable(var_name)
93				error('Missing dependency "@0@" for example "@1@"'.format(d, name))
94			endif
95			dep_objs += [get_variable(var_name)]
96		endforeach
97		if allow_experimental_apis
98			cflags += '-DALLOW_EXPERIMENTAL_API'
99		endif
100		executable('dpdk-' + name, sources,
101			include_directories: includes,
102			link_whole: driver_libs,
103			link_args: dpdk_extra_ldflags,
104			c_args: cflags,
105			dependencies: dep_objs)
106	elif not allow_skips
107		error('Cannot build requested example "' + name + '"')
108	else
109		message('Skipping example "' + name + '"')
110	endif
111endforeach
112