build: fix meson build in CI environments
[dpdk.git] / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 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')).stdout().strip(),
9         license: 'BSD',
10         default_options: ['buildtype=release', 'default_library=static'],
11         meson_version: '>= 0.47.1'
12 )
13
14 # set up some global vars for compiler, platform, configuration, etc.
15 cc = meson.get_compiler('c')
16 dpdk_conf = configuration_data()
17 dpdk_libraries = []
18 dpdk_static_libraries = []
19 dpdk_driver_classes = []
20 dpdk_drivers = []
21 dpdk_extra_ldflags = []
22 dpdk_app_link_libraries = []
23
24 # configure the build, and make sure configs here and in config folder are
25 # able to be included in any file. We also store a global array of include dirs
26 # for passing to pmdinfogen scripts
27 global_inc = include_directories('.', 'config', 'lib/librte_eal/common/include')
28 subdir('config')
29
30 # build libs and drivers
31 subdir('lib')
32 subdir('buildtools')
33 subdir('drivers')
34
35 # build binaries and installable tools
36 subdir('usertools')
37 subdir('app')
38
39 # build docs
40 subdir('doc')
41
42 # build any examples explicitly requested - useful for developers
43 if get_option('examples') != ''
44         subdir('examples')
45 endif
46
47 # build kernel modules if enabled
48 if get_option('enable_kmods')
49         subdir('kernel')
50 endif
51
52 # write the build config
53 build_cfg = 'rte_build_config.h'
54 configure_file(output: build_cfg,
55                 configuration: dpdk_conf,
56                 install_dir: join_paths(get_option('includedir'),
57                                 get_option('include_subdir_arch')))
58
59 # for static builds, include the drivers as libs and we need to "whole-archive"
60 # them.
61 dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
62
63 # driver .so files often depend upon the bus drivers for their connect bus,
64 # e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need
65 # to be in the library path, so symlink the drivers from the main lib directory.
66 meson.add_install_script('buildtools/symlink-drivers-solibs.sh',
67                 driver_install_path,
68                 get_option('libdir'))
69
70 pkg = import('pkgconfig')
71 pkg.generate(name: meson.project_name(),
72         filebase: 'lib' + meson.project_name().to_lower(),
73         version: meson.project_version(),
74         libraries: dpdk_libraries,
75         libraries_private: dpdk_drivers + dpdk_static_libraries +
76                         ['-Wl,-Bdynamic'] + dpdk_extra_ldflags,
77         description: '''The Data Plane Development Kit (DPDK).
78 Note that CFLAGS might contain an -march flag higher than typical baseline.
79 This is required for a number of static inline functions in the public headers.''',
80         subdirs: [get_option('include_subdir_arch'), '.'],
81         extra_cflags: ['-include', 'rte_config.h'] + machine_args
82 )
83
84 # final output, list all the libs and drivers to be built
85 # this does not affect any part of the build, for information only.
86 output_message = '\n=================\nLibraries Enabled\n=================\n'
87 output_message += '\nlibs:\n\t'
88 output_count = 0
89 foreach lib:enabled_libs
90         output_message += lib + ', '
91         output_count += 1
92         if output_count == 8
93                 output_message += '\n\t'
94                 output_count = 0
95         endif
96 endforeach
97 message(output_message + '\n')
98
99 output_message = '\n===============\nDrivers Enabled\n===============\n'
100 foreach class:dpdk_driver_classes
101         class_drivers = get_variable(class + '_drivers')
102         output_message += '\n' + class + ':\n\t'
103         output_count = 0
104         foreach drv:class_drivers
105                 output_message += drv + ', '
106                 output_count += 1
107                 if output_count == 8
108                         output_message += '\n\t'
109                         output_count = 0
110                 endif
111         endforeach
112 endforeach
113 message(output_message + '\n')