New upstream version 18.11.2
[deb_dpdk.git] / config / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 Intel Corporation
3
4 # driver .so files often depend upon the bus drivers for their connect bus,
5 # e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need
6 # to be in the library path, so symlink the drivers from the main lib directory.
7 meson.add_install_script('../buildtools/symlink-drivers-solibs.sh',
8                 get_option('libdir'),
9                 pmd_subdir_opt)
10
11 # set the machine type and cflags for it
12 if meson.is_cross_build()
13         machine = host_machine.cpu()
14 else
15         machine = get_option('machine')
16 endif
17
18 # machine type 'default' is special, it defaults to the per arch agreed common
19 # minimal baseline needed for DPDK.
20 # That might not be the most optimized, but the most portable version while
21 # still being able to support the CPU features required for DPDK.
22 # This can be bumped up by the DPDK project, but it can never be an
23 # invariant like 'native'
24 if machine == 'default'
25         if host_machine.cpu_family().startswith('x86')
26                 # matches the old pre-meson build systems default
27                 machine = 'corei7'
28         elif host_machine.cpu_family().startswith('arm')
29                 machine = 'armv7-a'
30         elif host_machine.cpu_family().startswith('aarch')
31                 # arm64 manages defaults in config/arm/meson.build
32                 machine = 'default'
33         elif host_machine.cpu_family().startswith('ppc')
34                 machine = 'power8'
35         endif
36 endif
37
38 dpdk_conf.set('RTE_MACHINE', machine)
39 machine_args = []
40
41 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
42 if host_machine.cpu_family().startswith('ppc')
43         machine_args += '-mcpu=' + machine
44         machine_args += '-mtune=' + machine
45 else
46         machine_args += '-march=' + machine
47 endif
48
49 toolchain = cc.get_id()
50 dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain)
51 dpdk_conf.set('RTE_TOOLCHAIN_' + toolchain.to_upper(), 1)
52
53 add_project_link_arguments('-Wl,--no-as-needed', language: 'c')
54 dpdk_extra_ldflags += '-Wl,--no-as-needed'
55
56 # use pthreads
57 add_project_link_arguments('-pthread', language: 'c')
58 dpdk_extra_ldflags += '-pthread'
59
60 # some libs depend on maths lib
61 add_project_link_arguments('-lm', language: 'c')
62 dpdk_extra_ldflags += '-lm'
63
64 # for linux link against dl, for bsd execinfo
65 if host_machine.system() == 'linux'
66         link_lib = 'dl'
67 else
68         link_lib = 'execinfo'
69 endif
70 add_project_link_arguments('-l' + link_lib, language: 'c')
71 dpdk_extra_ldflags += '-l' + link_lib
72
73 # check for libraries used in multiple places in DPDK
74 has_libnuma = 0
75 numa_dep = cc.find_library('numa', required: false)
76 if numa_dep.found() and cc.has_header('numaif.h')
77         dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
78         has_libnuma = 1
79         add_project_link_arguments('-lnuma', language: 'c')
80         dpdk_extra_ldflags += '-lnuma'
81 endif
82
83 # check for strlcpy
84 if host_machine.system() == 'linux' and cc.find_library('bsd',
85                 required: false).found() and cc.has_header('bsd/string.h')
86         dpdk_conf.set('RTE_USE_LIBBSD', 1)
87         add_project_link_arguments('-lbsd', language: 'c')
88         dpdk_extra_ldflags += '-lbsd'
89 endif
90
91 # add -include rte_config to cflags
92 add_project_arguments('-include', 'rte_config.h', language: 'c')
93
94 # enable extra warnings and disable any unwanted warnings
95 warning_flags = [
96         '-Wsign-compare',
97         '-Wcast-qual',
98         '-Wno-address-of-packed-member'
99 ]
100 if cc.sizeof('void *') == 4
101 # for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!!
102         warning_flags += '-Wno-pointer-to-int-cast'
103 endif
104 foreach arg: warning_flags
105         if cc.has_argument(arg)
106                 add_project_arguments(arg, language: 'c')
107         endif
108 endforeach
109
110 # set other values pulled from the build options
111 dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
112 dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
113 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
114 dpdk_conf.set('RTE_EAL_ALLOW_INV_SOCKET_ID', get_option('allow_invalid_socket_id'))
115 # values which have defaults which may be overridden
116 dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)
117 dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64)
118 dpdk_conf.set('RTE_LIBRTE_DPAA2_USE_PHYS_IOVA', true)
119
120 compile_time_cpuflags = []
121 if host_machine.cpu_family().startswith('x86')
122         arch_subdir = 'x86'
123 elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch')
124         arch_subdir = 'arm'
125 elif host_machine.cpu_family().startswith('ppc')
126         arch_subdir = 'ppc_64'
127 endif
128 subdir(arch_subdir)
129 dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
130
131 # set the install path for the drivers
132 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
133
134 install_headers('rte_config.h', subdir: get_option('include_subdir_arch'))
135
136 # enable VFIO only if it is linux OS
137 dpdk_conf.set('RTE_EAL_VFIO', host_machine.system() == 'linux')