build: add single source of DPDK version number
[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 # set the major version, which might be used by drivers and libraries
24 # depending on the configuration options
25 pver = meson.project_version().split('.')
26 major_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
27
28 pmd_subdir_opt = get_option('drivers_install_subdir')
29 if pmd_subdir_opt.contains('<VERSION>')
30         pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>'))
31 endif
32 driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt)
33 eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
34
35 # configure the build, and make sure configs here and in config folder are
36 # able to be included in any file. We also store a global array of include dirs
37 # for passing to pmdinfogen scripts
38 global_inc = include_directories('.', 'config', 'lib/librte_eal/common/include')
39 subdir('config')
40
41 # build libs and drivers
42 subdir('lib')
43 subdir('buildtools')
44 subdir('drivers')
45
46 # build binaries and installable tools
47 subdir('usertools')
48 subdir('app')
49
50 # build docs
51 subdir('doc')
52
53 # build any examples explicitly requested - useful for developers
54 if get_option('examples') != ''
55         subdir('examples')
56 endif
57
58 # build kernel modules if enabled
59 if get_option('enable_kmods')
60         subdir('kernel')
61 endif
62
63 # write the build config
64 build_cfg = 'rte_build_config.h'
65 configure_file(output: build_cfg,
66                 configuration: dpdk_conf,
67                 install_dir: join_paths(get_option('includedir'),
68                                 get_option('include_subdir_arch')))
69
70 # for static builds, include the drivers as libs and we need to "whole-archive"
71 # them.
72 dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
73
74 # driver .so files often depend upon the bus drivers for their connect bus,
75 # e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need
76 # to be in the library path, so symlink the drivers from the main lib directory.
77 meson.add_install_script('buildtools/symlink-drivers-solibs.sh',
78                 driver_install_path,
79                 get_option('libdir'))
80
81 pkg = import('pkgconfig')
82 pkg.generate(name: meson.project_name(),
83         filebase: 'lib' + meson.project_name().to_lower(),
84         version: meson.project_version(),
85         libraries: dpdk_libraries,
86         libraries_private: dpdk_drivers + dpdk_static_libraries +
87                         ['-Wl,-Bdynamic'] + dpdk_extra_ldflags,
88         description: '''The Data Plane Development Kit (DPDK).
89 Note that CFLAGS might contain an -march flag higher than typical baseline.
90 This is required for a number of static inline functions in the public headers.''',
91         subdirs: [get_option('include_subdir_arch'), '.'],
92         extra_cflags: ['-include', 'rte_config.h'] + machine_args
93 )
94
95 # final output, list all the libs and drivers to be built
96 # this does not affect any part of the build, for information only.
97 output_message = '\n=================\nLibraries Enabled\n=================\n'
98 output_message += '\nlibs:\n\t'
99 output_count = 0
100 foreach lib:enabled_libs
101         output_message += lib + ', '
102         output_count += 1
103         if output_count == 8
104                 output_message += '\n\t'
105                 output_count = 0
106         endif
107 endforeach
108 message(output_message + '\n')
109
110 output_message = '\n===============\nDrivers Enabled\n===============\n'
111 foreach class:dpdk_driver_classes
112         class_drivers = get_variable(class + '_drivers')
113         output_message += '\n' + class + ':\n\t'
114         output_count = 0
115         foreach drv:class_drivers
116                 output_message += drv + ', '
117                 output_count += 1
118                 if output_count == 8
119                         output_message += '\n\t'
120                         output_count = 0
121                 endif
122         endforeach
123 endforeach
124 message(output_message + '\n')