1# Copyright 2021 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15ncsid_headers = include_directories('.') 16 17fmt_dep = dependency('fmt', required: false) 18if not fmt_dep.found() 19 fmt_proj = import('cmake').subproject( 20 'fmt', 21 cmake_options: [ 22 '-DCMAKE_POSITION_INDEPENDENT_CODE=ON', 23 '-DMASTER_PROJECT=OFF' 24 ], 25 required: false) 26 assert(fmt_proj.found(), 'fmtlib is required') 27 fmt_dep = fmt_proj.dependency('fmt') 28endif 29 30ncsid_deps = [ 31 fmt_dep, 32 dependency('sdbusplus', fallback: ['sdbusplus', 'sdbusplus_dep']), 33 dependency('stdplus', fallback: ['stdplus', 'stdplus']), 34] 35 36ncsid_lib = static_library( 37 'ncsid', 38 [ 39 'net_config.cpp', 40 'net_iface.cpp', 41 'net_sockio.cpp', 42 'ncsi_sockio.cpp', 43 'ncsi_state_machine.cpp', 44 'platforms/nemora/portable/ncsi_fsm.c', 45 'platforms/nemora/portable/ncsi_client.c', 46 'platforms/nemora/portable/ncsi_server.c', 47 ], 48 include_directories: ncsid_headers, 49 implicit_include_directories: false, 50 dependencies: ncsid_deps) 51 52ncsid = declare_dependency( 53 dependencies: ncsid_deps, 54 include_directories: ncsid_headers, 55 link_with: ncsid_lib) 56 57executable( 58 'ncsid', 59 'ncsid.cpp', 60 implicit_include_directories: false, 61 dependencies: ncsid, 62 install: true, 63 install_dir: get_option('libexecdir')) 64 65normalize_ip = executable( 66 'normalize_ip', 67 'normalize_ip.c', 68 implicit_include_directories: false, 69 install: true) 70 71normalize_mac = executable( 72 'normalize_mac', 73 'normalize_mac.c', 74 implicit_include_directories: false, 75 install: true) 76 77install_data( 78 'ncsid_udhcpc4.script', 79 'ncsid_udhcpc6.script', 80 install_mode: 'rwxr-xr-x', 81 install_dir: get_option('libexecdir')) 82 83install_data( 84 'ncsid_lib.sh', 85 install_mode: 'rw-r--r--', 86 install_dir: get_option('libexecdir')) 87 88install_data( 89 'update_static_neighbors.sh', 90 install_mode: 'rwxr-xr-x', 91 install_dir: get_option('libexecdir')) 92 93systemd = dependency('systemd') 94systemunitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir') 95 96libexecdir = get_option('prefix') / get_option('libexecdir') 97 98configure_file( 99 configuration: {'BIN': libexecdir / 'ncsid'}, 100 input: 'ncsid@.service.in', 101 output: 'ncsid@.service', 102 install_mode: 'rw-r--r--', 103 install_dir: systemunitdir) 104 105configure_file( 106 configuration: {'BIN': libexecdir / 'update_static_neighbors.sh'}, 107 input: 'update-static-neighbors@.service.in', 108 output: 'update-static-neighbors@.service', 109 install_mode: 'rw-r--r--', 110 install_dir: systemunitdir) 111 112configure_file( 113 configuration: { 114 'SCRIPT': libexecdir / 'ncsid_udhcpc4.script'}, 115 input: 'dhcp4@.service.in', 116 output: 'dhcp4@.service', 117 install_mode: 'rw-r--r--', 118 install_dir: systemunitdir) 119 120configure_file( 121 configuration: { 122 'SCRIPT': libexecdir / 'ncsid_udhcpc6.script'}, 123 input: 'dhcp6@.service.in', 124 output: 'dhcp6@.service', 125 install_mode: 'rw-r--r--', 126 install_dir: systemunitdir) 127 128install_data( 129 'nic-hostful@.target', 130 'nic-hostless@.target', 131 'update-static-neighbors@.timer', 132 install_mode: 'rw-r--r--', 133 install_dir: systemunitdir) 134