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') == ''
26 if get_option('examples').to_lower() == 'all'
27 examples = all_examples
28 allow_skips = true # don't flag an error if we can't build an app
30 examples = get_option('examples').split(',')
31 allow_skips = false # error out if we can't build a requested app
33 default_cflags = machine_args
34 if cc.has_argument('-Wno-format-truncation')
35 default_cflags += '-Wno-format-truncation'
38 # specify -D_GNU_SOURCE unconditionally
39 default_cflags += '-D_GNU_SOURCE'
41 foreach example: examples
45 allow_experimental_apis = false
46 cflags = default_cflags
49 includes = [include_directories(example)]
50 deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
52 deps = ['eal'] # only supported lib on Windows currently
59 var_name = get_option('default_library') + '_rte_' + d
60 if not is_variable(var_name)
61 error('Missing dependency "@0@" for example "@1@"'.format(d, name))
63 dep_objs += [get_variable(var_name)]
65 if allow_experimental_apis
66 cflags += '-DALLOW_EXPERIMENTAL_API'
68 executable('dpdk-' + name, sources,
69 include_directories: includes,
70 link_whole: driver_libs,
71 link_args: dpdk_extra_ldflags,
73 dependencies: dep_objs)
75 error('Cannot build requested example "' + name + '"')
77 message('Skipping example "' + name + '"')