Brandon Kim | dab96f1 | 2021-02-18 11:21:37 -0800 | [diff] [blame] | 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 | |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 15 | ncsid_headers = include_directories('.') |
| 16 | |
| 17 | fmt_dep = dependency('fmt', required: false) |
| 18 | if 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') |
| 28 | endif |
| 29 | |
| 30 | ncsid_deps = [ |
| 31 | fmt_dep, |
| 32 | dependency('sdbusplus', fallback: ['sdbusplus', 'sdbusplus_dep']), |
William A. Kennington III | d237c6c | 2021-06-18 00:59:04 -0700 | [diff] [blame] | 33 | dependency('stdplus', fallback: ['stdplus', 'stdplus_dep']), |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 34 | ] |
| 35 | |
| 36 | ncsid_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 | |
| 52 | ncsid = declare_dependency( |
| 53 | dependencies: ncsid_deps, |
| 54 | include_directories: ncsid_headers, |
| 55 | link_with: ncsid_lib) |
| 56 | |
| 57 | executable( |
| 58 | 'ncsid', |
| 59 | 'ncsid.cpp', |
| 60 | implicit_include_directories: false, |
| 61 | dependencies: ncsid, |
| 62 | install: true, |
| 63 | install_dir: get_option('libexecdir')) |
| 64 | |
| 65 | normalize_ip = executable( |
| 66 | 'normalize_ip', |
| 67 | 'normalize_ip.c', |
| 68 | implicit_include_directories: false, |
| 69 | install: true) |
| 70 | |
| 71 | normalize_mac = executable( |
| 72 | 'normalize_mac', |
| 73 | 'normalize_mac.c', |
| 74 | implicit_include_directories: false, |
| 75 | install: true) |
| 76 | |
| 77 | install_data( |
| 78 | 'ncsid_udhcpc4.script', |
| 79 | 'ncsid_udhcpc6.script', |
William A. Kennington III | 379b061 | 2021-11-04 02:42:30 -0700 | [diff] [blame] | 80 | 'update_ra_gw.sh', |
| 81 | 'update_ra_neighbor.sh', |
| 82 | 'update_static_neighbors.sh', |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 83 | install_mode: 'rwxr-xr-x', |
| 84 | install_dir: get_option('libexecdir')) |
| 85 | |
| 86 | install_data( |
| 87 | 'ncsid_lib.sh', |
| 88 | install_mode: 'rw-r--r--', |
| 89 | install_dir: get_option('libexecdir')) |
| 90 | |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 91 | systemd = dependency('systemd') |
| 92 | systemunitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir') |
| 93 | |
| 94 | libexecdir = get_option('prefix') / get_option('libexecdir') |
| 95 | |
| 96 | configure_file( |
| 97 | configuration: {'BIN': libexecdir / 'ncsid'}, |
| 98 | input: 'ncsid@.service.in', |
| 99 | output: 'ncsid@.service', |
| 100 | install_mode: 'rw-r--r--', |
| 101 | install_dir: systemunitdir) |
| 102 | |
| 103 | configure_file( |
William A. Kennington III | 379b061 | 2021-11-04 02:42:30 -0700 | [diff] [blame] | 104 | configuration: {'BIN': libexecdir / 'update_ra_gw.sh'}, |
| 105 | input: 'update-ra-gw@.service.in', |
| 106 | output: 'update-ra-gw@.service', |
| 107 | install_mode: 'rw-r--r--', |
| 108 | install_dir: systemunitdir) |
| 109 | |
| 110 | configure_file( |
William A. Kennington III | b163a2c | 2021-05-20 17:33:01 -0700 | [diff] [blame] | 111 | configuration: {'BIN': libexecdir / 'update_ra_neighbor.sh'}, |
| 112 | input: 'update-ra-neighbor@.service.in', |
| 113 | output: 'update-ra-neighbor@.service', |
| 114 | install_mode: 'rw-r--r--', |
| 115 | install_dir: systemunitdir) |
| 116 | |
| 117 | configure_file( |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 118 | configuration: {'BIN': libexecdir / 'update_static_neighbors.sh'}, |
| 119 | input: 'update-static-neighbors@.service.in', |
| 120 | output: 'update-static-neighbors@.service', |
| 121 | install_mode: 'rw-r--r--', |
| 122 | install_dir: systemunitdir) |
| 123 | |
| 124 | configure_file( |
| 125 | configuration: { |
| 126 | 'SCRIPT': libexecdir / 'ncsid_udhcpc4.script'}, |
| 127 | input: 'dhcp4@.service.in', |
| 128 | output: 'dhcp4@.service', |
| 129 | install_mode: 'rw-r--r--', |
| 130 | install_dir: systemunitdir) |
| 131 | |
| 132 | configure_file( |
| 133 | configuration: { |
| 134 | 'SCRIPT': libexecdir / 'ncsid_udhcpc6.script'}, |
| 135 | input: 'dhcp6@.service.in', |
| 136 | output: 'dhcp6@.service', |
| 137 | install_mode: 'rw-r--r--', |
| 138 | install_dir: systemunitdir) |
| 139 | |
| 140 | install_data( |
| 141 | 'nic-hostful@.target', |
| 142 | 'nic-hostless@.target', |
William A. Kennington III | b163a2c | 2021-05-20 17:33:01 -0700 | [diff] [blame] | 143 | 'update-ra-neighbor@.timer', |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 144 | 'update-static-neighbors@.timer', |
| 145 | install_mode: 'rw-r--r--', |
| 146 | install_dir: systemunitdir) |