xref: /dpdk/examples/meson.build (revision 1dcbc676)
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',
12        'bond',
13        'cmdline',
14        'distributor',
15        'dma',
16        'ethtool',
17        'eventdev_pipeline',
18        'fips_validation',
19        'flow_classify',
20        'flow_filtering',
21        'helloworld',
22        'ip_fragmentation',
23        'ip_pipeline',
24        'ip_reassembly',
25        'ipsec-secgw',
26        'ipv4_multicast',
27        'kni',
28        'l2fwd',
29        'l2fwd-cat',
30        'l2fwd-crypto',
31        'l2fwd-event',
32        'l2fwd-jobstats',
33        'l2fwd-keepalive',
34        'l3fwd',
35        'l3fwd-acl',
36        'l3fwd-graph',
37        'l3fwd-power',
38        'link_status_interrupt',
39        'multi_process/client_server_mp/mp_client',
40        'multi_process/client_server_mp/mp_server',
41        'multi_process/hotplug_mp',
42        'multi_process/simple_mp',
43        'multi_process/symmetric_mp',
44        'ntb',
45        'packet_ordering',
46        'pipeline',
47        'ptpclient',
48        'qos_meter',
49        'qos_sched',
50        'rxtx_callbacks',
51        'server_node_efd/node',
52        'server_node_efd/server',
53        'service_cores',
54        'skeleton',
55        'timer',
56        'vdpa',
57        'vhost',
58        'vhost_blk',
59        'vhost_crypto',
60        'vm_power_manager',
61        'vm_power_manager/guest_cli',
62        'vmdq',
63        'vmdq_dcb',
64]
65
66# on install, skip copying all meson.build files
67ex_file_excludes = ['meson.build']
68foreach ex:all_examples
69    ex_file_excludes += [ex + '/meson.build']
70endforeach
71
72if get_option('examples') == ''
73    subdir_done()
74endif
75
76if get_option('examples').to_lower() == 'all'
77    examples = all_examples
78    allow_skips = true # don't flag an error if we can't build an app
79else
80    examples = get_option('examples').split(',')
81    allow_skips = false # error out if we can't build a requested app
82endif
83default_cflags = machine_args
84if cc.has_argument('-Wno-format-truncation')
85    default_cflags += '-Wno-format-truncation'
86endif
87default_ldflags = dpdk_extra_ldflags
88if get_option('default_library') == 'static' and not is_windows
89    default_ldflags += ['-Wl,--export-dynamic']
90endif
91
92foreach example: examples
93    name = example.split('/')[-1]
94    build = true
95    sources = []
96    allow_experimental_apis = false
97    cflags = default_cflags
98    ldflags = default_ldflags
99
100    ext_deps = []
101    includes = [include_directories(example)]
102    deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
103    subdir(example)
104
105    if build
106        dep_objs = ext_deps
107        foreach d:deps
108            var_name = get_option('default_library') + '_rte_' + d
109            if not is_variable(var_name)
110                build = false
111                message('Missing dependency "@0@" for example "@1@"'.format(d, name))
112                break
113            endif
114            dep_objs += [get_variable(var_name)]
115        endforeach
116    endif
117
118    if not build
119        if not allow_skips
120            error('Cannot build requested example "' + name + '"')
121        endif
122        message('Skipping example "' + name + '"')
123        continue
124    endif
125
126    if allow_experimental_apis
127        cflags += '-DALLOW_EXPERIMENTAL_API'
128    endif
129    executable('dpdk-' + name, sources,
130            include_directories: includes,
131            link_whole: link_whole_libs,
132            link_args: ldflags,
133            c_args: cflags,
134            dependencies: dep_objs)
135endforeach
136