xref: /dpdk/examples/meson.build (revision 68a03efeed657e6e05f281479b33b51102797e15)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2017-2019 Intel Corporation
3
4link_whole_libs = []
5if get_option('default_library') == 'static'
6	link_whole_libs = dpdk_static_libraries + dpdk_drivers
7endif
8
9# list of all example apps. Keep 1-3 per line, in alphabetical order.
10all_examples = [
11	'bbdev_app', 'bond',
12	'cmdline',
13	'distributor', 'ethtool',
14	'eventdev_pipeline',
15	'fips_validation', 'flow_classify',
16	'flow_filtering', 'helloworld',
17	'ioat',
18	'ip_fragmentation', 'ip_pipeline',
19	'ip_reassembly', 'ipsec-secgw',
20	'ipv4_multicast', 'kni',
21	'l2fwd', 'l2fwd-cat', 'l2fwd-event',
22	'l2fwd-crypto', 'l2fwd-jobstats',
23	'l2fwd-keepalive', 'l3fwd',
24	'l3fwd-acl', 'l3fwd-power', 'l3fwd-graph',
25	'link_status_interrupt',
26	'multi_process/client_server_mp/mp_client',
27	'multi_process/client_server_mp/mp_server',
28	'multi_process/hotplug_mp',
29	'multi_process/simple_mp',
30	'multi_process/symmetric_mp',
31	'ntb', 'packet_ordering',
32	'performance-thread/l3fwd-thread',
33	'performance-thread/pthread_shim',
34	'pipeline',
35	'ptpclient',
36	'qos_meter', 'qos_sched',
37	'rxtx_callbacks',
38	'server_node_efd/node',
39	'server_node_efd/server',
40	'service_cores',
41	'skeleton',
42	'timer', 'vdpa',
43	'vhost', 'vhost_crypto',
44	'vhost_blk', 'vm_power_manager',
45	'vm_power_manager/guest_cli',
46	'vmdq', 'vmdq_dcb',
47]
48
49# on install, skip copying all meson.build files
50ex_file_excludes = ['meson.build']
51foreach ex:all_examples
52	ex_file_excludes += [ex + '/meson.build']
53endforeach
54
55if get_option('examples') == ''
56	subdir_done()
57endif
58
59if get_option('examples').to_lower() == 'all'
60	examples = all_examples
61	allow_skips = true # don't flag an error if we can't build an app
62else
63	examples = get_option('examples').split(',')
64	allow_skips = false # error out if we can't build a requested app
65endif
66default_cflags = machine_args
67if cc.has_argument('-Wno-format-truncation')
68	default_cflags += '-Wno-format-truncation'
69endif
70default_ldflags = dpdk_extra_ldflags
71if get_option('default_library') == 'static' and not is_windows
72	default_ldflags += ['-Wl,--export-dynamic']
73endif
74
75foreach example: examples
76	name = example.split('/')[-1]
77	build = true
78	sources = []
79	allow_experimental_apis = false
80	cflags = default_cflags
81	ldflags = default_ldflags
82
83	ext_deps = []
84	includes = [include_directories(example)]
85	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
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: link_whole_libs,
103			link_args: 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