Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 2 | """ |
Davide Pesavento | 4c95771 | 2024-01-01 15:40:06 -0500 | [diff] [blame] | 3 | Copyright (c) 2014-2024, Regents of the University of California, |
taylorchu | 5ae2877 | 2015-03-08 17:45:52 -0700 | [diff] [blame] | 4 | Arizona Board of Regents, |
| 5 | Colorado State University, |
| 6 | University Pierre & Marie Curie, Sorbonne University, |
| 7 | Washington University in St. Louis, |
| 8 | Beijing Institute of Technology, |
| 9 | The University of Memphis. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | |
| 11 | This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | |
| 14 | NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | of the GNU General Public License as published by the Free Software Foundation, |
| 16 | either version 3 of the License, or (at your option) any later version. |
| 17 | |
| 18 | NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | PURPOSE. See the GNU General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License along with |
| 23 | NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | """ |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 25 | |
Davide Pesavento | a9e1ab2 | 2023-10-02 22:10:45 -0400 | [diff] [blame] | 26 | import os |
| 27 | import subprocess |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 28 | from waflib import Context, Logs, Utils |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 29 | |
Davide Pesavento | 3bc8e19 | 2022-12-31 01:40:11 -0500 | [diff] [blame] | 30 | VERSION = '22.12' |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 31 | APPNAME = 'nfd' |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 32 | GIT_TAG_PREFIX = 'NFD-' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 33 | |
| 34 | def options(opt): |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 35 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 4064127 | 2023-03-16 13:31:12 -0400 | [diff] [blame] | 36 | opt.load(['default-compiler-flags', 'pch', |
| 37 | 'coverage', 'sanitizers', 'boost', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 38 | 'dependency-checker', 'unix-socket', 'websocket', |
Davide Pesavento | 0d89d41 | 2024-03-13 14:20:02 -0400 | [diff] [blame] | 39 | 'doxygen', 'sphinx'], |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 40 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 41 | |
Davide Pesavento | 1752159 | 2020-05-14 19:01:32 -0400 | [diff] [blame] | 42 | optgrp = opt.add_option_group('NFD Options') |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 43 | |
Davide Pesavento | 1752159 | 2020-05-14 19:01:32 -0400 | [diff] [blame] | 44 | opt.addUnixOptions(optgrp) |
| 45 | opt.addDependencyOptions(optgrp, 'libresolv') |
| 46 | opt.addDependencyOptions(optgrp, 'librt') |
| 47 | opt.addDependencyOptions(optgrp, 'libpcap') |
| 48 | optgrp.add_option('--without-libpcap', action='store_true', default=False, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 49 | help='Disable libpcap (Ethernet face support will be disabled)') |
Davide Pesavento | 1752159 | 2020-05-14 19:01:32 -0400 | [diff] [blame] | 50 | optgrp.add_option('--without-systemd', action='store_true', default=False, |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 51 | help='Disable systemd integration') |
Davide Pesavento | 1752159 | 2020-05-14 19:01:32 -0400 | [diff] [blame] | 52 | opt.addWebsocketOptions(optgrp) |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 53 | |
Davide Pesavento | 1752159 | 2020-05-14 19:01:32 -0400 | [diff] [blame] | 54 | optgrp.add_option('--with-tests', action='store_true', default=False, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 55 | help='Build unit tests') |
Davide Pesavento | 1752159 | 2020-05-14 19:01:32 -0400 | [diff] [blame] | 56 | optgrp.add_option('--with-other-tests', action='store_true', default=False, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 57 | help='Build other tests') |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 58 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 59 | PRIVILEGE_CHECK_CODE = ''' |
| 60 | #include <unistd.h> |
| 61 | #include <grp.h> |
| 62 | #include <pwd.h> |
| 63 | int main() |
| 64 | { |
| 65 | sysconf(_SC_GETGR_R_SIZE_MAX); |
| 66 | |
| 67 | char buffer[100]; |
| 68 | group grp; |
| 69 | group* grpRes; |
| 70 | getgrnam_r("nogroup", &grp, buffer, 100, &grpRes); |
| 71 | passwd pwd; |
| 72 | passwd* pwdRes; |
| 73 | getpwnam_r("nobody", &pwd, buffer, 100, &pwdRes); |
| 74 | |
| 75 | int ret = setegid(grp.gr_gid); |
| 76 | ret = seteuid(pwd.pw_uid); |
| 77 | (void)(ret); |
| 78 | |
| 79 | getegid(); |
| 80 | geteuid(); |
| 81 | } |
| 82 | ''' |
Alexander Afanasyev | 8269a05 | 2015-02-09 16:25:36 -0800 | [diff] [blame] | 83 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 84 | def configure(conf): |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 85 | conf.load(['compiler_cxx', 'gnu_dirs', |
Davide Pesavento | 4064127 | 2023-03-16 13:31:12 -0400 | [diff] [blame] | 86 | 'default-compiler-flags', 'pch', |
| 87 | 'boost', 'dependency-checker', 'websocket', |
Davide Pesavento | 0d89d41 | 2024-03-13 14:20:02 -0400 | [diff] [blame] | 88 | 'doxygen', 'sphinx']) |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 89 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 90 | conf.env.WITH_TESTS = conf.options.with_tests |
| 91 | conf.env.WITH_OTHER_TESTS = conf.options.with_other_tests |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 92 | |
Davide Pesavento | 2150da8 | 2022-07-08 18:18:51 -0400 | [diff] [blame] | 93 | conf.find_program('bash') |
| 94 | conf.find_program('dot', mandatory=False) |
| 95 | |
| 96 | # Prefer pkgconf if it's installed, because it gives more correct results |
| 97 | # on Fedora/CentOS/RHEL/etc. See https://bugzilla.redhat.com/show_bug.cgi?id=1953348 |
| 98 | # Store the result in env.PKGCONFIG, which is the variable used inside check_cfg() |
| 99 | conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG') |
Davide Pesavento | f0ae442 | 2014-05-05 16:32:12 +0200 | [diff] [blame] | 100 | |
Davide Pesavento | deb5427 | 2022-03-11 18:51:05 -0500 | [diff] [blame] | 101 | pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig') |
Davide Pesavento | 3bc8e19 | 2022-12-31 01:40:11 -0500 | [diff] [blame] | 102 | conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'], |
Davide Pesavento | deb5427 | 2022-03-11 18:51:05 -0500 | [diff] [blame] | 103 | uselib_store='NDN_CXX', pkg_config_path=pkg_config_path) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 104 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 105 | if not conf.options.without_systemd: |
| 106 | conf.check_cfg(package='libsystemd', args=['--cflags', '--libs'], |
| 107 | uselib_store='SYSTEMD', mandatory=False) |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 108 | |
Davide Pesavento | b499a60 | 2014-11-18 22:36:56 +0100 | [diff] [blame] | 109 | conf.checkDependency(name='librt', lib='rt', mandatory=False) |
| 110 | conf.checkDependency(name='libresolv', lib='resolv', mandatory=False) |
| 111 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 112 | conf.check_cxx(msg='Checking if privilege drop/elevation is supported', mandatory=False, |
| 113 | define_name='HAVE_PRIVILEGE_DROP_AND_ELEVATE', fragment=PRIVILEGE_CHECK_CODE) |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 114 | |
Davide Pesavento | aaa5dd3 | 2016-09-02 12:33:33 +0000 | [diff] [blame] | 115 | conf.check_cxx(header_name='valgrind/valgrind.h', define_name='HAVE_VALGRIND', mandatory=False) |
Alexander Afanasyev | 49343f6 | 2015-01-26 21:58:07 -0800 | [diff] [blame] | 116 | |
Davide Pesavento | a9e1ab2 | 2023-10-02 22:10:45 -0400 | [diff] [blame] | 117 | conf.check_boost(lib='filesystem program_options', mt=True) |
| 118 | if conf.env.BOOST_VERSION_NUMBER < 107100: |
| 119 | conf.fatal('The minimum supported version of Boost is 1.71.0.\n' |
Davide Pesavento | 1752159 | 2020-05-14 19:01:32 -0400 | [diff] [blame] | 120 | 'Please upgrade your distribution or manually install a newer version of Boost.\n' |
| 121 | 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 122 | |
Davide Pesavento | a9e1ab2 | 2023-10-02 22:10:45 -0400 | [diff] [blame] | 123 | if conf.env.WITH_TESTS or conf.env.WITH_OTHER_TESTS: |
| 124 | conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS') |
| 125 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 126 | conf.load('unix-socket') |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 127 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 128 | if not conf.options.without_libpcap: |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 129 | conf.checkDependency(name='libpcap', lib='pcap', |
Davide Pesavento | 5f35f64 | 2018-05-10 19:36:03 -0400 | [diff] [blame] | 130 | errmsg='not found, but required for Ethernet face support. ' |
| 131 | 'Specify --without-libpcap to disable Ethernet face support.') |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 132 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 133 | conf.checkWebsocket() |
Davide Pesavento | 774071c | 2018-11-15 21:33:23 -0500 | [diff] [blame] | 134 | |
Alexander Afanasyev | b522070 | 2017-09-21 18:57:00 -0400 | [diff] [blame] | 135 | conf.check_compiler_flags() |
| 136 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 137 | # Loading "late" to prevent tests from being compiled with profiling flags |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 138 | conf.load('coverage') |
Eric Newberry | 27bdd1a | 2016-11-01 18:02:54 -0700 | [diff] [blame] | 139 | conf.load('sanitizers') |
| 140 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 141 | conf.define_cond('WITH_TESTS', conf.env.WITH_TESTS) |
| 142 | conf.define_cond('WITH_OTHER_TESTS', conf.env.WITH_OTHER_TESTS) |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame] | 143 | conf.define('DEFAULT_CONFIG_FILE', f'{conf.env.SYSCONFDIR}/ndn/nfd.conf') |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 144 | # The config header will contain all defines that were added using conf.define() |
| 145 | # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES |
| 146 | # will not appear in the config header, but will instead be passed directly to the |
| 147 | # compiler on the command line. |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 148 | conf.write_config_header('core/config.hpp', define_prefix='NFD_') |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 149 | |
Junxiao Shi | 09bf7c4 | 2014-01-31 11:10:25 -0700 | [diff] [blame] | 150 | def build(bld): |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 151 | versionhpp(bld) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 152 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 153 | bld(features='subst', |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 154 | name='version.cpp', |
| 155 | source='core/version.cpp.in', |
| 156 | target='core/version.cpp', |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 157 | install_path=None, |
| 158 | VERSION_STRING=VERSION_BASE, |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 159 | VERSION_BUILD=VERSION) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 160 | |
Davide Pesavento | a314808 | 2018-04-12 18:21:54 -0400 | [diff] [blame] | 161 | bld.objects( |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 162 | target='core-objects', |
Davide Pesavento | a9e1ab2 | 2023-10-02 22:10:45 -0400 | [diff] [blame] | 163 | source=bld.path.find_dir('core').ant_glob('*.cpp') + ['core/version.cpp'], |
| 164 | use='version.cpp version.hpp BOOST NDN_CXX LIBRT', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 165 | includes='.', |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 166 | export_includes='.') |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 167 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 168 | nfd_objects = bld.objects( |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 169 | target='daemon-objects', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 170 | source=bld.path.ant_glob('daemon/**/*.cpp', |
Davide Pesavento | fe0580c | 2017-05-12 02:02:10 -0400 | [diff] [blame] | 171 | excl=['daemon/face/*ethernet*.cpp', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 172 | 'daemon/face/pcap*.cpp', |
| 173 | 'daemon/face/unix*.cpp', |
| 174 | 'daemon/face/websocket*.cpp', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 175 | 'daemon/main.cpp']), |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 176 | features='pch', |
| 177 | headers='daemon/nfd-pch.hpp', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 178 | use='core-objects', |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 179 | includes='daemon', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 180 | export_includes='daemon') |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 181 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 182 | if bld.env.HAVE_LIBPCAP: |
Davide Pesavento | fe0580c | 2017-05-12 02:02:10 -0400 | [diff] [blame] | 183 | nfd_objects.source += bld.path.ant_glob('daemon/face/*ethernet*.cpp') |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 184 | nfd_objects.source += bld.path.ant_glob('daemon/face/pcap*.cpp') |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 185 | nfd_objects.use += ' LIBPCAP' |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 186 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 187 | if bld.env.HAVE_UNIX_SOCKETS: |
| 188 | nfd_objects.source += bld.path.ant_glob('daemon/face/unix*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 189 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 190 | if bld.env.HAVE_WEBSOCKET: |
| 191 | nfd_objects.source += bld.path.ant_glob('daemon/face/websocket*.cpp') |
| 192 | nfd_objects.use += ' WEBSOCKET' |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 193 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 194 | if bld.env.WITH_OTHER_TESTS: |
Eric Newberry | 69b63dc | 2017-11-04 15:42:46 -0700 | [diff] [blame] | 195 | nfd_objects.source += bld.path.ant_glob('tests/other/fw/*.cpp') |
| 196 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 197 | bld.program(name='nfd', |
| 198 | target='bin/nfd', |
| 199 | source='daemon/main.cpp', |
Davide Pesavento | 1b077f6 | 2019-02-19 19:19:44 -0500 | [diff] [blame] | 200 | use='daemon-objects SYSTEMD') |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 201 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 202 | bld.recurse('tests') |
Davide Pesavento | a9e1ab2 | 2023-10-02 22:10:45 -0400 | [diff] [blame] | 203 | bld.recurse('tools') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 204 | |
Davide Pesavento | a9e1ab2 | 2023-10-02 22:10:45 -0400 | [diff] [blame] | 205 | # Install sample configs |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 206 | bld(features='subst', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 207 | source='nfd.conf.sample.in', |
| 208 | target='nfd.conf.sample', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 209 | install_path='${SYSCONFDIR}/ndn', |
| 210 | IF_HAVE_LIBPCAP='' if bld.env.HAVE_LIBPCAP else '; ', |
Eric Newberry | 2297490 | 2020-04-06 23:41:00 -0700 | [diff] [blame] | 211 | IF_HAVE_WEBSOCKET='' if bld.env.HAVE_WEBSOCKET else '; ', |
Davide Pesavento | 4c95771 | 2024-01-01 15:40:06 -0500 | [diff] [blame] | 212 | UNIX_SOCKET_PATH='/run/nfd/nfd.sock' if Utils.unversioned_sys_platform() == 'linux' else '/var/run/nfd/nfd.sock') |
Davide Pesavento | f392b8f | 2019-01-08 20:51:55 -0500 | [diff] [blame] | 213 | bld.install_files('${SYSCONFDIR}/ndn', 'autoconfig.conf.sample') |
| 214 | |
Davide Pesavento | 6ecc3f8 | 2019-02-17 22:23:08 -0500 | [diff] [blame] | 215 | if bld.env.HAVE_SYSTEMD: |
Davide Pesavento | f392b8f | 2019-01-08 20:51:55 -0500 | [diff] [blame] | 216 | systemd_units = bld.path.ant_glob('systemd/*.in') |
| 217 | bld(features='subst', |
| 218 | name='systemd-units', |
| 219 | source=systemd_units, |
| 220 | target=[u.change_ext('') for u in systemd_units]) |
| 221 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 222 | if bld.env.SPHINX_BUILD: |
| 223 | bld(features='sphinx', |
| 224 | name='manpages', |
| 225 | builder='man', |
| 226 | config='docs/conf.py', |
| 227 | outdir='docs/manpages', |
Davide Pesavento | 08b91c8 | 2019-04-13 19:42:10 -0400 | [diff] [blame] | 228 | source=bld.path.ant_glob('docs/manpages/*.rst'), |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 229 | install_path='${MANDIR}', |
Davide Pesavento | 08b91c8 | 2019-04-13 19:42:10 -0400 | [diff] [blame] | 230 | version=VERSION_BASE, |
| 231 | release=VERSION) |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 232 | bld.symlink_as('${MANDIR}/man1/nfdc-channel.1', 'nfdc-face.1') |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 233 | bld.symlink_as('${MANDIR}/man1/nfdc-fib.1', 'nfdc-route.1') |
| 234 | bld.symlink_as('${MANDIR}/man1/nfdc-register.1', 'nfdc-route.1') |
| 235 | bld.symlink_as('${MANDIR}/man1/nfdc-unregister.1', 'nfdc-route.1') |
| 236 | bld.symlink_as('${MANDIR}/man1/nfdc-set-strategy.1', 'nfdc-strategy.1') |
| 237 | bld.symlink_as('${MANDIR}/man1/nfdc-unset-strategy.1', 'nfdc-strategy.1') |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 238 | |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 239 | def versionhpp(bld): |
| 240 | version(bld) |
| 241 | |
Alexander Afanasyev | 5006c1d | 2022-01-27 14:31:20 -0500 | [diff] [blame] | 242 | vmajor = int(VERSION_SPLIT[0]) |
| 243 | vminor = int(VERSION_SPLIT[1]) if len(VERSION_SPLIT) >= 2 else 0 |
| 244 | vpatch = int(VERSION_SPLIT[2]) if len(VERSION_SPLIT) >= 3 else 0 |
| 245 | |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 246 | bld(features='subst', |
| 247 | name='version.hpp', |
| 248 | source='core/version.hpp.in', |
| 249 | target='core/version.hpp', |
| 250 | install_path=None, |
Alexander Afanasyev | 5006c1d | 2022-01-27 14:31:20 -0500 | [diff] [blame] | 251 | VERSION=vmajor * 1000000 + vminor * 1000 + vpatch, |
| 252 | VERSION_MAJOR=str(vmajor), |
| 253 | VERSION_MINOR=str(vminor), |
| 254 | VERSION_PATCH=str(vpatch)) |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 255 | |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 256 | def docs(bld): |
| 257 | from waflib import Options |
| 258 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 259 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 260 | def doxygen(bld): |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 261 | versionhpp(bld) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 262 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 263 | if not bld.env.DOXYGEN: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 264 | bld.fatal('Cannot build documentation ("doxygen" not found in PATH)') |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 265 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 266 | bld(features='subst', |
| 267 | name='doxygen.conf', |
| 268 | source=['docs/doxygen.conf.in', |
| 269 | 'docs/named_data_theme/named_data_footer-with-analytics.html.in'], |
| 270 | target=['docs/doxygen.conf', |
| 271 | 'docs/named_data_theme/named_data_footer-with-analytics.html'], |
| 272 | VERSION=VERSION, |
Davide Pesavento | a47cca2 | 2021-04-16 02:30:11 -0400 | [diff] [blame] | 273 | HAVE_DOT='YES' if bld.env.DOT else 'NO', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 274 | HTML_FOOTER='../build/docs/named_data_theme/named_data_footer-with-analytics.html' \ |
| 275 | if os.getenv('GOOGLE_ANALYTICS', None) \ |
| 276 | else '../docs/named_data_theme/named_data_footer.html', |
| 277 | GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', '')) |
| 278 | |
| 279 | bld(features='doxygen', |
| 280 | doxyfile='docs/doxygen.conf', |
Davide Pesavento | 03f45d2 | 2019-04-04 12:34:26 -0400 | [diff] [blame] | 281 | use='doxygen.conf version.hpp') |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 282 | |
| 283 | def sphinx(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 284 | version(bld) |
| 285 | |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 286 | if not bld.env.SPHINX_BUILD: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 287 | bld.fatal('Cannot build documentation ("sphinx-build" not found in PATH)') |
| 288 | |
| 289 | bld(features='sphinx', |
| 290 | config='docs/conf.py', |
| 291 | outdir='docs', |
| 292 | source=bld.path.ant_glob('docs/**/*.rst'), |
Davide Pesavento | 08b91c8 | 2019-04-13 19:42:10 -0400 | [diff] [blame] | 293 | version=VERSION_BASE, |
| 294 | release=VERSION) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 295 | |
| 296 | def version(ctx): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 297 | # don't execute more than once |
Alexander Afanasyev | 2618153 | 2014-05-07 23:38:51 -0700 | [diff] [blame] | 298 | if getattr(Context.g_module, 'VERSION_BASE', None): |
| 299 | return |
| 300 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 301 | Context.g_module.VERSION_BASE = Context.g_module.VERSION |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 302 | Context.g_module.VERSION_SPLIT = VERSION_BASE.split('.') |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 303 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 304 | # first, try to get a version string from git |
Davide Pesavento | e1dc79b | 2024-04-21 18:48:23 -0400 | [diff] [blame] | 305 | version_from_git = '' |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 306 | try: |
Davide Pesavento | e1dc79b | 2024-04-21 18:48:23 -0400 | [diff] [blame] | 307 | cmd = ['git', 'describe', '--abbrev=8', '--always', '--match', f'{GIT_TAG_PREFIX}*'] |
| 308 | version_from_git = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip() |
| 309 | if version_from_git: |
Davide Pesavento | c3bf8ad | 2024-05-03 20:20:54 -0400 | [diff] [blame^] | 310 | if GIT_TAG_PREFIX and version_from_git.startswith(GIT_TAG_PREFIX): |
| 311 | Context.g_module.VERSION = version_from_git[len(GIT_TAG_PREFIX):] |
| 312 | elif not GIT_TAG_PREFIX and ('.' in version_from_git or '-' in version_from_git): |
| 313 | Context.g_module.VERSION = version_from_git |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 314 | else: |
Davide Pesavento | c3bf8ad | 2024-05-03 20:20:54 -0400 | [diff] [blame^] | 315 | # no tags matched (or we are in a shallow clone) |
Davide Pesavento | e1dc79b | 2024-04-21 18:48:23 -0400 | [diff] [blame] | 316 | Context.g_module.VERSION = f'{VERSION_BASE}+git.{version_from_git}' |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame] | 317 | except (OSError, subprocess.SubprocessError): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 318 | pass |
| 319 | |
Davide Pesavento | e1dc79b | 2024-04-21 18:48:23 -0400 | [diff] [blame] | 320 | # fallback to the VERSION.info file, if it exists and is not empty |
| 321 | version_from_file = '' |
| 322 | version_file = ctx.path.find_node('VERSION.info') |
| 323 | if version_file is not None: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 324 | try: |
Davide Pesavento | e1dc79b | 2024-04-21 18:48:23 -0400 | [diff] [blame] | 325 | version_from_file = version_file.read().strip() |
| 326 | except OSError as e: |
| 327 | Logs.warn(f'{e.filename} exists but is not readable ({e.strerror})') |
| 328 | if version_from_file and not version_from_git: |
| 329 | Context.g_module.VERSION = version_from_file |
| 330 | return |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 331 | |
Davide Pesavento | e1dc79b | 2024-04-21 18:48:23 -0400 | [diff] [blame] | 332 | # update VERSION.info if necessary |
| 333 | if version_from_file == Context.g_module.VERSION: |
| 334 | # already up-to-date |
| 335 | return |
| 336 | if version_file is None: |
| 337 | version_file = ctx.path.make_node('VERSION.info') |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 338 | try: |
Davide Pesavento | e1dc79b | 2024-04-21 18:48:23 -0400 | [diff] [blame] | 339 | version_file.write(Context.g_module.VERSION) |
| 340 | except OSError as e: |
| 341 | Logs.warn(f'{e.filename} is not writable ({e.strerror})') |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 342 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 343 | def dist(ctx): |
Davide Pesavento | 39c67f6 | 2023-02-15 00:26:26 -0500 | [diff] [blame] | 344 | ctx.algo = 'tar.xz' |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 345 | version(ctx) |
| 346 | |
| 347 | def distcheck(ctx): |
Davide Pesavento | 39c67f6 | 2023-02-15 00:26:26 -0500 | [diff] [blame] | 348 | ctx.algo = 'tar.xz' |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 349 | version(ctx) |