xref: /dpdk/examples/meson.build (revision 089e5ed727a15da2729cfee9b63533dd120bd04c)
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	'bpf', 'cmdline',
15	'distributor', 'ethtool',
16	'eventdev_pipeline', 'exception_path',
17	'fips_validation', 'flow_classify',
18	'flow_filtering', 'helloworld',
19	'ip_fragmentation', 'ip_pipeline',
20	'ip_reassembly', 'ipsec-secgw',
21	'ipv4_multicast', 'kni',
22	'l2fwd', 'l2fwd-cat',
23	'l2fwd-crypto', 'l2fwd-jobstats',
24	'l2fwd-keepalive', 'l3fwd',
25	'l3fwd-acl', 'l3fwd-power',
26	'l3fwd-vf', 'link_status_interrupt',
27	'load_balancer',
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	'netmap_compat', 'ntb', 'packet_ordering',
34	'performance-thread', 'ptpclient',
35	'qos_meter', 'qos_sched',
36	'quota_watermark', 'rxtx_callbacks',
37	'server_node_efd', 'service_cores',
38	'skeleton', 'tep_termination',
39	'timer', 'vdpa',
40	'vhost', 'vhost_crypto',
41	'vhost_scsi', 'vm_power_manager',
42	'vmdq', 'vmdq_dcb',
43]
44# install all example code on install - irrespective of whether the example in
45# question is to be built as part of this build or not.
46foreach ex:all_examples
47	install_subdir(ex,
48			install_dir: get_option('datadir') + '/dpdk/examples',
49			exclude_files: 'meson.build')
50endforeach
51
52if get_option('examples') == ''
53	subdir_done()
54endif
55
56if get_option('examples').to_lower() == 'all'
57	examples = all_examples
58	allow_skips = true # don't flag an error if we can't build an app
59else
60	examples = get_option('examples').split(',')
61	allow_skips = false # error out if we can't build a requested app
62endif
63default_cflags = machine_args
64if cc.has_argument('-Wno-format-truncation')
65	default_cflags += '-Wno-format-truncation'
66endif
67
68foreach example: examples
69	name = example.split('/')[-1]
70	build = true
71	sources = []
72	allow_experimental_apis = false
73	cflags = default_cflags
74
75	ext_deps = [execinfo]
76	includes = [include_directories(example)]
77	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
78	if is_windows
79		deps = ['eal'] # only supported lib on Windows currently
80	endif
81	subdir(example)
82
83	if build
84		dep_objs = ext_deps
85		foreach d:deps
86			var_name = get_option('default_library') + '_rte_' + d
87			if not is_variable(var_name)
88				error('Missing dependency "@0@" for example "@1@"'.format(d, name))
89			endif
90			dep_objs += [get_variable(var_name)]
91		endforeach
92		if allow_experimental_apis
93			cflags += '-DALLOW_EXPERIMENTAL_API'
94		endif
95		executable('dpdk-' + name, sources,
96			include_directories: includes,
97			link_whole: driver_libs,
98			link_args: dpdk_extra_ldflags,
99			c_args: cflags,
100			dependencies: dep_objs)
101	elif not allow_skips
102		error('Cannot build requested example "' + name + '"')
103	else
104		message('Skipping example "' + name + '"')
105	endif
106endforeach
107