1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2017 Intel Corporation 3 4project('DPDK', 'C', 5 version: '18.11.5', 6 license: 'BSD', 7 default_options: ['buildtype=release', 'default_library=static'], 8 meson_version: '>= 0.41' 9) 10 11# set up some global vars for compiler, platform, configuration, etc. 12cc = meson.get_compiler('c') 13dpdk_conf = configuration_data() 14dpdk_libraries = [] 15dpdk_static_libraries = [] 16dpdk_drivers = [] 17dpdk_extra_ldflags = [] 18dpdk_app_link_libraries = [] 19 20# set the major version, which might be used by drivers and libraries 21# depending on the configuration options 22pver = meson.project_version().split('.') 23major_version = '@0@.@1@'.format(pver.get(0), pver.get(1)) 24 25pmd_subdir_opt = get_option('drivers_install_subdir') 26if pmd_subdir_opt.contains('<VERSION>') 27 pmd_subdir_opt = major_version.join(pmd_subdir_opt.split('<VERSION>')) 28endif 29driver_install_path = join_paths(get_option('libdir'), pmd_subdir_opt) 30eal_pmd_path = join_paths(get_option('prefix'), driver_install_path) 31 32# configure the build, and make sure configs here and in config folder are 33# able to be included in any file. We also store a global array of include dirs 34# for passing to pmdinfogen scripts 35global_inc = include_directories('.', 'config') 36subdir('config') 37 38# build libs and drivers 39subdir('lib') 40subdir('buildtools') 41subdir('drivers') 42 43# build binaries and installable tools 44subdir('usertools') 45subdir('app') 46subdir('test') 47 48# build docs 49subdir('doc') 50 51# build any examples explicitly requested - useful for developers 52if get_option('examples') != '' 53 subdir('examples') 54endif 55 56# build kernel modules if enabled 57if get_option('enable_kmods') 58 subdir('kernel') 59endif 60 61# write the build config 62build_cfg = 'rte_build_config.h' 63configure_file(output: build_cfg, 64 configuration: dpdk_conf, 65 install_dir: join_paths(get_option('includedir'), 66 get_option('include_subdir_arch'))) 67 68# for static builds, include the drivers as libs and we need to "whole-archive" 69# them. 70dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive'] 71 72pkg = import('pkgconfig') 73pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args 74if host_machine.system() == 'freebsd' 75 pkg_extra_cflags += ['-D__BSD_VISIBLE'] 76endif 77pkg.generate(name: meson.project_name(), 78 filebase: 'lib' + meson.project_name().to_lower(), 79 version: meson.project_version(), 80 libraries: dpdk_libraries, 81 libraries_private: dpdk_drivers + dpdk_static_libraries + 82 ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, 83 description: '''The Data Plane Development Kit (DPDK). 84Note that CFLAGS might contain an -march flag higher than typical baseline. 85This is required for a number of static inline functions in the public headers.''', 86 subdirs: [get_option('include_subdir_arch'), '.'], 87 extra_cflags: pkg_extra_cflags 88) 89 90# final output, list all the libs and drivers to be built 91# this does not affect any part of the build, for information only. 92output_message = '\n=================\nLibraries Enabled\n=================\n' 93output_message += '\nlibs:\n\t' 94output_count = 0 95foreach lib:enabled_libs 96 output_message += lib + ', ' 97 output_count += 1 98 if output_count == 8 99 output_message += '\n\t' 100 output_count = 0 101 endif 102endforeach 103message(output_message + '\n') 104 105 106# prior to 0.47 set_variable didn't work with arrays, so we can't 107# track driver lists easily 108if meson.version().version_compare('>=0.47') 109 output_message = '\n===============\nDrivers Enabled\n===============\n' 110 foreach class:driver_classes 111 class_drivers = get_variable(class + '_drivers') 112 output_message += '\n' + class + ':\n\t' 113 output_count = 0 114 foreach drv:class_drivers 115 output_message += drv + ', ' 116 output_count += 1 117 if output_count == 8 118 output_message += '\n\t' 119 output_count = 0 120 endif 121 endforeach 122 endforeach 123 message(output_message + '\n') 124endif 125