build: remove architecture flag as default C flag
[dpdk.git] / config / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 Intel Corporation
3
4 # set the machine type and cflags for it
5 if meson.is_cross_build()
6         machine = host_machine.cpu()
7 else
8         machine = get_option('machine')
9 endif
10 dpdk_conf.set('RTE_MACHINE', machine)
11 machine_arg = '-march=' + machine
12
13 # use pthreads
14 add_project_link_arguments('-pthread', language: 'c')
15 dpdk_extra_ldflags += '-pthread'
16
17 # some libs depend on maths lib
18 add_project_link_arguments('-lm', language: 'c')
19 dpdk_extra_ldflags += '-lm'
20
21 # for linux link against dl, for bsd execinfo
22 if host_machine.system() == 'linux'
23         link_lib = 'dl'
24 else
25         link_lib = 'execinfo'
26 endif
27 add_project_link_arguments('-l' + link_lib, language: 'c')
28 dpdk_extra_ldflags += '-l' + link_lib
29
30 # check for libraries used in multiple places in DPDK
31 has_libnuma = 0
32 numa_dep = cc.find_library('numa', required: false)
33 if numa_dep.found() and cc.has_header('numaif.h')
34         dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
35         has_libnuma = 1
36         add_project_link_arguments('-lnuma', language: 'c')
37         dpdk_extra_ldflags += '-lnuma'
38 endif
39
40 # add -include rte_config to cflags
41 add_project_arguments('-include', 'rte_config.h', language: 'c')
42
43 # enable extra warnings and disable any unwanted warnings
44 warning_flags = [
45         '-Wsign-compare',
46         '-Wcast-qual',
47         '-Wno-address-of-packed-member',
48         '-Wno-format-truncation'
49 ]
50 foreach arg: warning_flags
51         if cc.has_argument(arg)
52                 add_project_arguments(arg, language: 'c')
53         endif
54 endforeach
55
56 compile_time_cpuflags = []
57 if host_machine.cpu_family().startswith('x86')
58         arch_subdir = 'x86'
59         subdir(arch_subdir)
60 endif
61 dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
62
63 # set the install path for the drivers
64 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
65
66 # set other values pulled from the build options
67 dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
68 dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
69 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
70 dpdk_conf.set('RTE_EAL_ALLOW_INV_SOCKET_ID', get_option('allow_invalid_socket_id'))
71 # values which have defaults which may be overridden
72 dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)
73
74 install_headers('rte_config.h', subdir: get_option('include_subdir_arch'))