examples/performance-thread: add pthread shim to meson
[dpdk.git] / examples / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
3
4 driver_libs = []
5 if get_option('default_library') == 'static'
6         driver_libs = dpdk_drivers
7 endif
8
9 execinfo = cc.find_library('execinfo', required: false)
10
11 # list of all example apps. Keep 1-3 per line, in alphabetical order.
12 all_examples = [
13         'bbdev_app', 'bond',
14         'cmdline',
15         'distributor', 'ethtool',
16         'eventdev_pipeline',
17         'fips_validation', 'flow_classify',
18         'flow_filtering', 'helloworld',
19         'ip_fragmentation', 'ip_pipeline',
20         'ip_reassembly', 'ipsec-secgw',
21         'ipv4_multicast', 'kni',
22         'l2fwd', 'l2fwd-cat',
23         'l2fwd-crypto', 'l2fwd-jobstats',
24         'l2fwd-keepalive', 'l3fwd',
25         'l3fwd-acl', 'l3fwd-power',
26         'link_status_interrupt',
27         'multi_process/client_server_mp/mp_client',
28         'multi_process/client_server_mp/mp_server',
29         'multi_process/hotplug_mp',
30         'multi_process/simple_mp',
31         'multi_process/symmetric_mp',
32         'ntb', 'packet_ordering',
33         'performance-thread/l3fwd-thread',
34         'performance-thread/pthread_shim',
35         'ptpclient',
36         'qos_meter', 'qos_sched',
37         'rxtx_callbacks',
38         'server_node_efd', 'service_cores',
39         'skeleton', 'tep_termination',
40         'timer', 'vdpa',
41         'vhost', 'vhost_crypto',
42         'vm_power_manager',
43         'vmdq', 'vmdq_dcb',
44 ]
45 # install all example code on install - irrespective of whether the example in
46 # question is to be built as part of this build or not.
47 foreach ex:all_examples
48         install_subdir(ex,
49                         install_dir: get_option('datadir') + '/dpdk/examples',
50                         exclude_files: 'meson.build')
51 endforeach
52
53 if get_option('examples') == ''
54         subdir_done()
55 endif
56
57 if get_option('examples').to_lower() == 'all'
58         examples = all_examples
59         allow_skips = true # don't flag an error if we can't build an app
60 else
61         examples = get_option('examples').split(',')
62         allow_skips = false # error out if we can't build a requested app
63 endif
64 default_cflags = machine_args
65 if cc.has_argument('-Wno-format-truncation')
66         default_cflags += '-Wno-format-truncation'
67 endif
68
69 foreach example: examples
70         name = example.split('/')[-1]
71         build = true
72         sources = []
73         allow_experimental_apis = false
74         cflags = default_cflags
75
76         ext_deps = [execinfo]
77         includes = [include_directories(example)]
78         deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
79         if is_windows
80                 deps = ['eal'] # only supported lib on Windows currently
81         endif
82         subdir(example)
83
84         if build
85                 dep_objs = ext_deps
86                 foreach d:deps
87                         var_name = get_option('default_library') + '_rte_' + d
88                         if not is_variable(var_name)
89                                 error('Missing dependency "@0@" for example "@1@"'.format(d, name))
90                         endif
91                         dep_objs += [get_variable(var_name)]
92                 endforeach
93                 if allow_experimental_apis
94                         cflags += '-DALLOW_EXPERIMENTAL_API'
95                 endif
96                 executable('dpdk-' + name, sources,
97                         include_directories: includes,
98                         link_whole: driver_libs,
99                         link_args: dpdk_extra_ldflags,
100                         c_args: cflags,
101                         dependencies: dep_objs)
102         elif not allow_skips
103                 error('Cannot build requested example "' + name + '"')
104         else
105                 message('Skipping example "' + name + '"')
106         endif
107 endforeach