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