xref: /dpdk/examples/meson.build (revision a4f56123)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2017 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
11allow_skips = true # don't flag an error if we can't build an app
12
13if get_option('examples').to_lower() == 'all'
14	dirs = run_command('sh', '-c',
15		'cd $MESON_SOURCE_ROOT/$MESON_SUBDIR && for d in * ; do if [ -d $d ] ; then echo $d ; fi ; done')
16	examples = dirs.stdout().split()
17else
18	examples = get_option('examples').split(',')
19	allow_skips = false # error out if we can't build a requested app
20endif
21default_cflags = machine_args
22if cc.has_argument('-Wno-format-truncation')
23	default_cflags += '-Wno-format-truncation'
24endif
25foreach example: examples
26	name = example
27	build = true
28	sources = []
29	allow_experimental_apis = false
30	cflags = default_cflags
31
32	ext_deps = [execinfo]
33	includes = [include_directories(example)]
34	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
35	subdir(example)
36
37	if build
38		dep_objs = ext_deps
39		foreach d:deps
40			var_name = get_option('default_library') + '_rte_' + d
41			if not is_variable(var_name)
42				error('Missing dependency "@0@" for example "@1@"'.format(d, name))
43			endif
44			dep_objs += [get_variable(var_name)]
45		endforeach
46		if allow_experimental_apis
47			cflags += '-DALLOW_EXPERIMENTAL_API'
48		endif
49		executable('dpdk-' + name, sources,
50			include_directories: includes,
51			link_whole: driver_libs,
52			link_args: dpdk_extra_ldflags,
53			c_args: cflags,
54			dependencies: dep_objs)
55	elif not allow_skips
56		error('Cannot build requested example "' + name + '"')
57	else
58		message('Skipping example "' + name + '"')
59	endif
60endforeach
61