build: add infrastructure for meson and ninja builds
[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'],
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 # for static libs, treat the drivers as regular libraries, otherwise
47 # for shared libs, put them in a driver folder
48 if get_option('default_library') == 'static'
49         driver_install_path = get_option('libdir')
50         eal_pmd_path = ''
51 else
52         driver_install_path = join_paths(get_option('datadir'), 'dpdk/drivers')
53         eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
54 endif
55
56 # configure the build, and make sure configs here and in config folder are
57 # able to be included in any file. We also store a global array of include dirs
58 # for passing to pmdinfogen scripts
59 global_inc = include_directories('.', 'config')
60 subdir('config')
61
62 # TODO build libs and drivers
63
64 # TODO build binaries and installable tools
65
66 # write the build config
67 build_cfg = 'rte_build_config.h'
68 configure_file(output: build_cfg,
69                 configuration: dpdk_conf,
70                 install_dir: get_option('includedir'))
71
72 # for static builds, include the drivers as libs, and also any
73 # other dependent libs that DPDK needs to link against
74 if get_option('default_library') == 'static'
75         dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
76         dpdk_libraries = dpdk_drivers + dpdk_libraries + dpdk_extra_ldflags
77 endif
78
79 pkg = import('pkgconfig')
80 pkg.generate(name: meson.project_name(),
81         version: meson.project_version(),
82         libraries: dpdk_libraries,
83         description: 'The Data Plane Development Kit (DPDK)',
84         extra_cflags: ['-include', 'rte_config.h', '-march=@0@'.format(machine)]
85 )