71a0c4f17006fcf4d8e03a51342e991368dd762f
[dpdk.git] / meson.build
1 #   BSD LICENSE
2 #
3 #   Copyright(c) 2017 Intel Corporation.
4 #   All rights reserved.
5 #
6 #   Redistribution and use in source and binary forms, with or without
7 #   modification, are permitted provided that the following conditions
8 #   are met:
9 #
10 #     * Redistributions of source code must retain the above copyright
11 #       notice, this list of conditions and the following disclaimer.
12 #     * Redistributions in binary form must reproduce the above copyright
13 #       notice, this list of conditions and the following disclaimer in
14 #       the documentation and/or other materials provided with the
15 #       distribution.
16 #     * Neither the name of Intel Corporation nor the names of its
17 #       contributors may be used to endorse or promote products derived
18 #       from this software without specific prior written permission.
19 #
20 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 #   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 #   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 #   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 #   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 #   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 project('DPDK', 'C',
33         version: '18.02.0',
34         license: 'BSD',
35         default_options: ['buildtype=release', 'default_library=static'],
36         meson_version: '>= 0.41'
37 )
38
39 # set up some global vars for compiler, platform, configuration, etc.
40 cc = meson.get_compiler('c')
41 dpdk_conf = configuration_data()
42 dpdk_libraries = []
43 dpdk_drivers = []
44 dpdk_extra_ldflags = []
45
46 driver_install_path = join_paths(get_option('libdir'), 'dpdk/drivers')
47 eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
48
49 # configure the build, and make sure configs here and in config folder are
50 # able to be included in any file. We also store a global array of include dirs
51 # for passing to pmdinfogen scripts
52 global_inc = include_directories('.', 'config')
53 subdir('config')
54
55 # build libs and drivers
56 subdir('lib')
57 subdir('buildtools')
58 subdir('drivers')
59
60 # build binaries and installable tools
61 subdir('usertools')
62 subdir('app')
63
64 # build any examples explicitly requested - useful for developers
65 if get_option('examples') != ''
66         subdir('examples')
67 endif
68
69 # write the build config
70 build_cfg = 'rte_build_config.h'
71 configure_file(output: build_cfg,
72                 configuration: dpdk_conf,
73                 install_dir: join_paths(get_option('includedir'),
74                                 get_option('include_subdir_arch')))
75
76 # for static builds, include the drivers as libs and we need to "whole-archive"
77 # them.
78 dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
79
80 pkg = import('pkgconfig')
81 pkg.generate(name: meson.project_name(),
82         filebase: 'lib' + meson.project_name().to_lower(),
83         version: meson.project_version(),
84         libraries: dpdk_libraries,
85         libraries_private: dpdk_drivers + dpdk_libraries +
86                         ['-Wl,-Bdynamic'] + dpdk_extra_ldflags,
87         description: 'The Data Plane Development Kit (DPDK)',
88         subdirs: [get_option('include_subdir_arch'), '.'],
89         extra_cflags: ['-include', 'rte_config.h', '-march=@0@'.format(machine)]
90 )