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