William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-networkd', |
| 3 | 'cpp', |
| 4 | version: '0.1', |
| 5 | meson_version: '>=0.57.0', |
| 6 | default_options: [ |
| 7 | 'warning_level=3', |
| 8 | 'cpp_std=c++20', |
| 9 | ]) |
| 10 | |
William A. Kennington III | 1e710d0 | 2021-05-24 13:35:44 -0700 | [diff] [blame^] | 11 | default_busname = 'xyz.openbmc_project.Network' |
| 12 | |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 13 | conf_data = configuration_data() |
William A. Kennington III | 1e710d0 | 2021-05-24 13:35:44 -0700 | [diff] [blame^] | 14 | conf_data.set_quoted('DEFAULT_BUSNAME', default_busname) |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 15 | conf_data.set('HAVE_UBOOT_ENV', get_option('uboot-env')) |
| 16 | conf_data.set( |
| 17 | 'LINK_LOCAL_AUTOCONFIGURATION', |
| 18 | get_option('default-link-local-autoconf')) |
| 19 | conf_data.set( |
| 20 | 'ENABLE_IPV6_ACCEPT_RA', |
| 21 | get_option('default-ipv6-accept-ra')) |
| 22 | conf_data.set('NIC_SUPPORTS_ETHTOOL', get_option('nic-ethtool')) |
| 23 | conf_data.set('SYNC_MAC_FROM_INVENTORY', get_option('sync-mac')) |
| 24 | conf_header = configure_file( |
| 25 | output: 'config.h', |
| 26 | configuration: conf_data) |
| 27 | |
| 28 | sdbusplus_dep = dependency('sdbusplus', required: false) |
| 29 | if sdbusplus_dep.found() |
| 30 | sdbusplusplus_prog = find_program('sdbus++', native: true) |
| 31 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) |
| 32 | else |
| 33 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 34 | sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 35 | sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') |
| 36 | sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable('sdbuspp_gen_meson_prog') |
| 37 | endif |
| 38 | |
| 39 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 40 | phosphor_logging_dep = dependency('phosphor-logging') |
| 41 | |
| 42 | generated_sources = [ conf_header ] |
| 43 | generated_others = [] |
| 44 | yaml_sources = [] |
| 45 | subdir('gen') |
| 46 | subdir('gen/xyz') |
| 47 | |
| 48 | networkd_headers = include_directories('.', 'gen') |
| 49 | |
| 50 | executable( |
| 51 | 'ncsi-netlink', |
| 52 | 'argument.cpp', |
| 53 | 'ncsi_netlink_main.cpp', |
| 54 | 'ncsi_util.cpp', |
| 55 | implicit_include_directories: false, |
| 56 | include_directories: networkd_headers, |
| 57 | dependencies: [ |
| 58 | dependency('libnl-3.0'), |
| 59 | dependency('libnl-genl-3.0'), |
| 60 | phosphor_dbus_interfaces_dep, |
| 61 | phosphor_logging_dep, |
| 62 | ], |
| 63 | install: true, |
| 64 | install_dir: get_option('bindir')) |
| 65 | |
| 66 | json_dep = declare_dependency() |
| 67 | if get_option('sync-mac') |
| 68 | # nlohmann_json might not have a pkg-config. It is header only so just make |
| 69 | # sure we can access the needed symbols from the header. |
| 70 | has_json = meson.get_compiler('cpp').has_header_symbol( |
| 71 | 'nlohmann/json.hpp', |
| 72 | 'nlohmann::json::string_t', |
| 73 | required: false) |
| 74 | if not has_json |
| 75 | json_dep = dependency( |
| 76 | 'nlohmann_json', |
| 77 | fallback: ['nlohmann_json', 'nlohmann_json_dep'], |
| 78 | required: true) |
| 79 | endif |
| 80 | endif |
| 81 | |
| 82 | networkd_deps = [ |
| 83 | json_dep, |
| 84 | phosphor_dbus_interfaces_dep, |
| 85 | phosphor_logging_dep, |
| 86 | sdbusplus_dep, |
| 87 | dependency('sdeventplus', fallback: ['sdeventplus', 'sdeventplus_dep']), |
| 88 | dependency('stdplus', fallback: ['stdplus', 'stdplus_dep']), |
| 89 | ] |
| 90 | |
| 91 | networkd_lib = static_library( |
| 92 | 'networkd', |
| 93 | generated_sources, |
| 94 | 'ethernet_interface.cpp', |
| 95 | 'neighbor.cpp', |
| 96 | 'ipaddress.cpp', |
| 97 | 'netlink.cpp', |
| 98 | 'network_config.cpp', |
| 99 | 'network_manager.cpp', |
| 100 | 'system_configuration.cpp', |
| 101 | 'util.cpp', |
| 102 | 'routing_table.cpp', |
| 103 | 'config_parser.cpp', |
| 104 | 'dhcp_configuration.cpp', |
| 105 | 'vlan_interface.cpp', |
| 106 | 'rtnetlink_server.cpp', |
| 107 | 'dns_updater.cpp', |
| 108 | 'watch.cpp', |
| 109 | implicit_include_directories: false, |
| 110 | include_directories: networkd_headers, |
| 111 | dependencies: networkd_deps) |
| 112 | |
| 113 | networkd_dep = declare_dependency( |
| 114 | sources: generated_sources, |
| 115 | dependencies: networkd_deps, |
| 116 | include_directories: networkd_headers, |
| 117 | link_with: networkd_lib) |
| 118 | |
| 119 | executable( |
| 120 | 'phosphor-network-manager', |
| 121 | 'network_manager_main.cpp', |
| 122 | implicit_include_directories: false, |
| 123 | dependencies: networkd_dep, |
| 124 | install: true, |
| 125 | install_dir: get_option('bindir')) |
| 126 | |
| 127 | configure_file( |
| 128 | input: 'xyz.openbmc_project.Network.service.in', |
| 129 | output: 'xyz.openbmc_project.Network.service', |
William A. Kennington III | 1e710d0 | 2021-05-24 13:35:44 -0700 | [diff] [blame^] | 130 | configuration: { |
| 131 | 'SYSTEMD_TARGET': 'multi-user.target', |
| 132 | 'DEFAULT_BUSNAME': default_busname, |
| 133 | }, |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 134 | install: true, |
| 135 | install_dir: dependency('systemd').get_variable( |
| 136 | pkgconfig: 'systemdsystemunitdir')) |
| 137 | |
| 138 | configure_file( |
| 139 | input: 'xyz.openbmc_project.Network.conf.in', |
| 140 | output: 'xyz.openbmc_project.Network.conf', |
William A. Kennington III | 1e710d0 | 2021-05-24 13:35:44 -0700 | [diff] [blame^] | 141 | configuration: {'DEFAULT_BUSNAME': default_busname}, |
William A. Kennington III | 0a01b2a | 2021-05-13 18:38:57 -0700 | [diff] [blame] | 142 | install: true, |
| 143 | install_dir: get_option('datadir') / 'dbus-1' / 'system.d') |
| 144 | |
| 145 | if not get_option('tests').disabled() |
| 146 | subdir('test') |
| 147 | endif |