build: add definitions for use as Meson subproject
[dpdk.git] / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
3
4 project('DPDK', 'C',
5         # Get version number from file.
6         # Fallback to "more" for Windows compatibility.
7         version: run_command(find_program('cat', 'more'),
8             files('VERSION'), check: true).stdout().strip(),
9         license: 'BSD',
10         default_options: [
11             'buildtype=release',
12             'default_library=static',
13             'warning_level=2',
14         ],
15         meson_version: '>= 0.49.2'
16 )
17
18 # check for developer mode
19 developer_mode = false
20 if get_option('developer_mode').auto()
21     if meson.version().version_compare('>=0.53') # fs module available
22         fs = import('fs')
23         developer_mode = fs.is_dir('.git')
24     endif
25 else
26     developer_mode = get_option('developer_mode').enabled()
27 endif
28 if developer_mode
29     message('## Building in Developer Mode ##')
30 endif
31
32 # set up some global vars for compiler, platform, configuration, etc.
33 cc = meson.get_compiler('c')
34 dpdk_source_root = meson.current_source_dir()
35 dpdk_build_root = meson.current_build_dir()
36 dpdk_conf = configuration_data()
37 dpdk_libraries = []
38 dpdk_static_libraries = []
39 dpdk_shared_lib_deps = []
40 dpdk_static_lib_deps = []
41 dpdk_chkinc_headers = []
42 dpdk_driver_classes = []
43 dpdk_drivers = []
44 dpdk_extra_ldflags = []
45 dpdk_libs_disabled = []
46 dpdk_drvs_disabled = []
47 testpmd_drivers_sources = []
48 testpmd_drivers_deps = []
49 abi_version_file = files('ABI_VERSION')
50
51 if host_machine.cpu_family().startswith('x86')
52     arch_subdir = 'x86'
53 elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch')
54     arch_subdir = 'arm'
55 elif host_machine.cpu_family().startswith('ppc')
56     arch_subdir = 'ppc'
57 endif
58
59 # configure the build, and make sure configs here and in config folder are
60 # able to be included in any file. We also store a global array of include dirs
61 # for passing to pmdinfogen scripts
62 global_inc = include_directories('.', 'config',
63     'lib/eal/include',
64     'lib/eal/@0@/include'.format(host_machine.system()),
65     'lib/eal/@0@/include'.format(arch_subdir),
66 )
67
68 # do configuration and get tool paths
69 subdir('buildtools')
70 subdir('config')
71
72 # build libs and drivers
73 subdir('lib')
74 subdir('drivers')
75
76 # build binaries and installable tools
77 subdir('usertools')
78 subdir('app')
79
80 # build docs
81 subdir('doc')
82
83 # build any examples explicitly requested - useful for developers - and
84 # install any example code into the appropriate install path
85 subdir('examples')
86 install_subdir('examples',
87         install_dir: get_option('datadir') + '/dpdk',
88         exclude_files: ex_file_excludes)
89
90 # build kernel modules if enabled
91 if get_option('enable_kmods')
92     subdir('kernel')
93 endif
94
95 # check header includes if requested
96 if get_option('check_includes')
97     subdir('buildtools/chkincs')
98 endif
99
100 # write the build config
101 build_cfg = 'rte_build_config.h'
102 configure_file(output: build_cfg,
103         configuration: dpdk_conf,
104         install_dir: join_paths(get_option('includedir'),
105             get_option('include_subdir_arch')))
106
107 # build pkg-config files for dpdk
108 subdir('buildtools/pkg-config')
109
110 if meson.is_subproject()
111     subdir('buildtools/subproject')
112 endif
113
114 # final output, list all the libs and drivers to be built
115 # this does not affect any part of the build, for information only.
116 output_message = '\n=================\nLibraries Enabled\n=================\n'
117 output_message += '\nlibs:\n\t'
118 output_count = 0
119 foreach lib:enabled_libs
120     output_message += lib + ', '
121     output_count += 1
122     if output_count == 8
123         output_message += '\n\t'
124         output_count = 0
125     endif
126 endforeach
127 message(output_message + '\n')
128
129 output_message = '\n===============\nDrivers Enabled\n===============\n'
130 foreach class:dpdk_driver_classes
131     class_drivers = get_variable(class + '_drivers')
132     output_message += '\n' + class + ':\n\t'
133     output_count = 0
134     foreach drv:class_drivers
135         output_message += drv + ', '
136         output_count += 1
137         if output_count == 8
138             output_message += '\n\t'
139             output_count = 0
140         endif
141     endforeach
142 endforeach
143 message(output_message + '\n')
144
145 output_message = '\n=================\nContent Skipped\n=================\n'
146 output_message += '\nlibs:\n\t'
147 foreach lib:dpdk_libs_disabled
148     reason = get_variable(lib.underscorify() + '_disable_reason')
149     output_message += lib + ':\t' + reason + '\n\t'
150 endforeach
151 output_message += '\ndrivers:\n\t'
152 foreach drv:dpdk_drvs_disabled
153     reason = get_variable(drv.underscorify() + '_disable_reason')
154     output_message += drv + ':\t' + reason + '\n\t'
155 endforeach
156 message(output_message + '\n')