xref: /f-stack/dpdk/examples/meson.build (revision fa64a7ff)
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
25
26foreach example: examples
27	name = example
28	build = true
29	sources = []
30	allow_experimental_apis = false
31	cflags = default_cflags
32
33	ext_deps = [execinfo]
34	includes = [include_directories(example)]
35	deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
36	subdir(example)
37
38	if build
39		dep_objs = ext_deps
40		foreach d:deps
41			var_name = get_option('default_library') + '_rte_' + d
42			if not is_variable(var_name)
43				error('Missing dependency "@0@" for example "@1@"'.format(d, name))
44			endif
45			dep_objs += [get_variable(var_name)]
46		endforeach
47		if allow_experimental_apis
48			cflags += '-DALLOW_EXPERIMENTAL_API'
49		endif
50		executable('dpdk-' + name, sources,
51			include_directories: includes,
52			link_whole: driver_libs,
53			link_args: dpdk_extra_ldflags,
54			c_args: cflags,
55			dependencies: dep_objs)
56	elif not allow_skips
57		error('Cannot build requested example "' + name + '"')
58	else
59		message('Skipping example "' + name + '"')
60	endif
61endforeach
62