1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
5 if get_option('default_library') == 'static'
6 driver_libs = dpdk_drivers
9 execinfo = cc.find_library('execinfo', required: false)
11 all_examples = run_command('sh', '-c',
12 'cd $MESON_SOURCE_ROOT/$MESON_SUBDIR && for d in * ; do if [ -d $d ] ; then echo $d ; fi ; done'
14 # install all example code on install - irrespective of whether the example in
15 # question is to be built as part of this build or not.
16 foreach ex:all_examples
18 install_dir: get_option('datadir') + '/dpdk/examples',
19 exclude_files: 'meson.build')
22 if get_option('examples').to_lower() == 'all'
23 examples = all_examples
24 allow_skips = true # don't flag an error if we can't build an app
26 examples = get_option('examples').split(',')
27 allow_skips = false # error out if we can't build a requested app
29 default_cflags = machine_args
30 if cc.has_argument('-Wno-format-truncation')
31 default_cflags += '-Wno-format-truncation'
34 # specify -D_GNU_SOURCE unconditionally
35 default_cflags += '-D_GNU_SOURCE'
37 foreach example: examples
41 allow_experimental_apis = false
42 cflags = default_cflags
45 includes = [include_directories(example)]
46 deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
48 deps = ['eal'] # only supported lib on Windows currently
55 var_name = get_option('default_library') + '_rte_' + d
56 if not is_variable(var_name)
57 error('Missing dependency "@0@" for example "@1@"'.format(d, name))
59 dep_objs += [get_variable(var_name)]
61 if allow_experimental_apis
62 cflags += '-DALLOW_EXPERIMENTAL_API'
64 executable('dpdk-' + name, sources,
65 include_directories: includes,
66 link_whole: driver_libs,
67 link_args: dpdk_extra_ldflags,
69 dependencies: dep_objs)
71 error('Cannot build requested example "' + name + '"')
73 message('Skipping example "' + name + '"')