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 | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 3 | Copyright (c) 2014-2018, 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 | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 26 | from waflib import Context, Logs, Utils |
| 27 | import os, subprocess |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 28 | |
Alexander Afanasyev | 782a1d1 | 2018-05-02 16:23:26 -0400 | [diff] [blame] | 29 | VERSION = '0.6.2' |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 30 | APPNAME = 'nfd' |
| 31 | BUGREPORT = 'https://redmine.named-data.net/projects/nfd' |
| 32 | URL = 'https://named-data.net/doc/NFD/' |
| 33 | GIT_TAG_PREFIX = 'NFD-' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 34 | |
| 35 | def options(opt): |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 36 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 37 | opt.load(['default-compiler-flags', 'compiler-features', 'type_traits', |
| 38 | 'coverage', 'pch', 'sanitizers', 'boost', 'boost-kqueue', |
| 39 | 'dependency-checker', 'unix-socket', 'websocket', |
| 40 | 'doxygen', 'sphinx_build'], |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 41 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 42 | |
| 43 | nfdopt = opt.add_option_group('NFD Options') |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 44 | opt.addUnixOptions(nfdopt) |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 45 | opt.addWebsocketOptions(nfdopt) |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 46 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 47 | opt.addDependencyOptions(nfdopt, 'libpcap') |
| 48 | nfdopt.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)') |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 50 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 51 | opt.addDependencyOptions(nfdopt, 'librt') |
| 52 | opt.addDependencyOptions(nfdopt, 'libresolv') |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 53 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 54 | nfdopt.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') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 56 | nfdopt.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 | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 86 | 'default-compiler-flags', 'compiler-features', 'type_traits', |
Eric Newberry | 27bdd1a | 2016-11-01 18:02:54 -0700 | [diff] [blame] | 87 | 'pch', 'boost', 'boost-kqueue', 'dependency-checker', 'websocket', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 88 | 'doxygen', 'sphinx_build']) |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 89 | |
Davide Pesavento | f0ae442 | 2014-05-05 16:32:12 +0200 | [diff] [blame] | 90 | conf.find_program('bash', var='BASH') |
| 91 | |
taylorchu | 5ae2877 | 2015-03-08 17:45:52 -0700 | [diff] [blame] | 92 | if 'PKG_CONFIG_PATH' not in os.environ: |
Alexander Afanasyev | cdb8f36 | 2015-03-30 10:52:54 -0700 | [diff] [blame] | 93 | os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env) |
Alexander Afanasyev | 4a77136 | 2014-04-24 21:29:33 -0700 | [diff] [blame] | 94 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 95 | uselib_store='NDN_CXX', mandatory=True) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 96 | |
Davide Pesavento | b499a60 | 2014-11-18 22:36:56 +0100 | [diff] [blame] | 97 | conf.checkDependency(name='librt', lib='rt', mandatory=False) |
| 98 | conf.checkDependency(name='libresolv', lib='resolv', mandatory=False) |
| 99 | |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 100 | if not conf.check_cxx(msg='Checking if privilege drop/elevation is supported', mandatory=False, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 101 | define_name='HAVE_PRIVILEGE_DROP_AND_ELEVATE', fragment=PRIVILEGE_CHECK_CODE): |
Junxiao Shi | a5765d6 | 2017-08-09 04:07:46 +0000 | [diff] [blame] | 102 | Logs.warn('Dropping privileges is not supported on this platform') |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 103 | |
Davide Pesavento | aaa5dd3 | 2016-09-02 12:33:33 +0000 | [diff] [blame] | 104 | 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] | 105 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 106 | if conf.options.with_tests: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 107 | conf.env.WITH_TESTS = True |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 108 | conf.define('WITH_TESTS', 1) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 109 | |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 110 | if conf.options.with_other_tests: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 111 | conf.env.WITH_OTHER_TESTS = True |
Eric Newberry | 52ae329 | 2017-11-16 13:54:52 -0700 | [diff] [blame] | 112 | conf.define('WITH_OTHER_TESTS', 1) |
| 113 | |
| 114 | boost_libs = 'system chrono program_options thread log log_setup' |
| 115 | if conf.options.with_tests or conf.options.with_other_tests: |
| 116 | boost_libs += ' unit_test_framework' |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 117 | |
Yumin Xia | ab49745 | 2016-05-10 20:23:24 +0800 | [diff] [blame] | 118 | conf.check_boost(lib=boost_libs, mt=True) |
Davide Pesavento | cafae24 | 2016-04-22 02:21:35 +0200 | [diff] [blame] | 119 | if conf.env.BOOST_VERSION_NUMBER < 105400: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 120 | conf.fatal('Minimum required Boost version is 1.54.0\n' |
| 121 | 'Please upgrade your distribution or manually install a newer version of Boost' |
| 122 | ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 123 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 124 | if conf.env.CXX_NAME == 'clang' and conf.env.BOOST_VERSION_NUMBER < 105800: |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 125 | conf.define('BOOST_ASIO_HAS_STD_ARRAY', 1) # Workaround for https://redmine.named-data.net/issues/3360#note-14 |
Eric Newberry | cb27ea8 | 2016-07-19 12:40:52 -0700 | [diff] [blame] | 126 | conf.define('BOOST_ASIO_HAS_STD_CHRONO', 1) # Solution documented at https://redmine.named-data.net/issues/3588#note-10 |
Alexander Afanasyev | 6602b3b | 2016-03-15 14:14:11 -0700 | [diff] [blame] | 127 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 128 | conf.load('unix-socket') |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 129 | conf.checkWebsocket(mandatory=True) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 130 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 131 | if not conf.options.without_libpcap: |
Alexander Afanasyev | e918621 | 2014-08-23 20:15:48 -0700 | [diff] [blame] | 132 | conf.check_asio_pcap_support() |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 133 | if conf.env.HAVE_ASIO_PCAP_SUPPORT: |
Alexander Afanasyev | e918621 | 2014-08-23 20:15:48 -0700 | [diff] [blame] | 134 | conf.checkDependency(name='libpcap', lib='pcap', mandatory=True, |
| 135 | errmsg='not found, but required for Ethernet face support. ' |
| 136 | 'Specify --without-libpcap to disable Ethernet face support.') |
| 137 | else: |
Junxiao Shi | a5765d6 | 2017-08-09 04:07:46 +0000 | [diff] [blame] | 138 | Logs.warn('Warning: Ethernet face is not supported on this platform with Boost libraries version 1.56. ' |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 139 | 'See https://redmine.named-data.net/issues/1877 for more details') |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 140 | if conf.env.HAVE_LIBPCAP: |
| 141 | conf.check_cxx(msg='Checking if libpcap supports pcap_set_immediate_mode', mandatory=False, |
| 142 | define_name='HAVE_PCAP_SET_IMMEDIATE_MODE', use='LIBPCAP', |
| 143 | fragment='''#include <pcap/pcap.h> |
| 144 | int main() { pcap_t* p; pcap_set_immediate_mode(p, 1); }''') |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 145 | |
Alexander Afanasyev | b522070 | 2017-09-21 18:57:00 -0400 | [diff] [blame] | 146 | conf.check_compiler_flags() |
| 147 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 148 | # Loading "late" to prevent tests from being compiled with profiling flags |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 149 | conf.load('coverage') |
Eric Newberry | 27bdd1a | 2016-11-01 18:02:54 -0700 | [diff] [blame] | 150 | conf.load('sanitizers') |
| 151 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 152 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env.SYSCONFDIR) |
Junxiao Shi | 759f706 | 2014-11-29 10:19:22 -0700 | [diff] [blame] | 153 | # disable assertions in release builds |
| 154 | if not conf.options.debug: |
| 155 | conf.define('NDEBUG', 1) |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 156 | conf.write_config_header('core/config.hpp') |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 157 | |
Junxiao Shi | 09bf7c4 | 2014-01-31 11:10:25 -0700 | [diff] [blame] | 158 | def build(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 159 | version(bld) |
| 160 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 161 | bld(features='subst', |
| 162 | name='version.hpp', |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 163 | source='core/version.hpp.in', |
| 164 | target='core/version.hpp', |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 165 | install_path=None, |
| 166 | VERSION_STRING=VERSION_BASE, |
| 167 | VERSION_BUILD=VERSION, |
| 168 | VERSION=int(VERSION_SPLIT[0]) * 1000000 + |
| 169 | int(VERSION_SPLIT[1]) * 1000 + |
| 170 | int(VERSION_SPLIT[2]), |
| 171 | VERSION_MAJOR=VERSION_SPLIT[0], |
| 172 | VERSION_MINOR=VERSION_SPLIT[1], |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 173 | VERSION_PATCH=VERSION_SPLIT[2]) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 174 | |
Davide Pesavento | a314808 | 2018-04-12 18:21:54 -0400 | [diff] [blame^] | 175 | bld.objects( |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 176 | target='core-objects', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 177 | features='pch', |
Davide Pesavento | a314808 | 2018-04-12 18:21:54 -0400 | [diff] [blame^] | 178 | source=bld.path.ant_glob('core/**/*.cpp'), |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 179 | use='version.hpp NDN_CXX BOOST LIBRT', |
| 180 | includes='.', |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 181 | export_includes='.', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 182 | headers='core/common.hpp') |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 183 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 184 | nfd_objects = bld.objects( |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 185 | target='daemon-objects', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 186 | source=bld.path.ant_glob('daemon/**/*.cpp', |
Davide Pesavento | fe0580c | 2017-05-12 02:02:10 -0400 | [diff] [blame] | 187 | excl=['daemon/face/*ethernet*.cpp', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 188 | 'daemon/face/pcap*.cpp', |
| 189 | 'daemon/face/unix*.cpp', |
| 190 | 'daemon/face/websocket*.cpp', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 191 | 'daemon/main.cpp']), |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 192 | use='core-objects', |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 193 | includes='daemon', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 194 | export_includes='daemon') |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 195 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 196 | if bld.env.HAVE_LIBPCAP: |
Davide Pesavento | fe0580c | 2017-05-12 02:02:10 -0400 | [diff] [blame] | 197 | nfd_objects.source += bld.path.ant_glob('daemon/face/*ethernet*.cpp') |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 198 | nfd_objects.source += bld.path.ant_glob('daemon/face/pcap*.cpp') |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 199 | nfd_objects.use += ' LIBPCAP' |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 200 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 201 | if bld.env.HAVE_UNIX_SOCKETS: |
| 202 | nfd_objects.source += bld.path.ant_glob('daemon/face/unix*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 203 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 204 | if bld.env.HAVE_WEBSOCKET: |
| 205 | nfd_objects.source += bld.path.ant_glob('daemon/face/websocket*.cpp') |
| 206 | nfd_objects.use += ' WEBSOCKET' |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 207 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 208 | if bld.env.WITH_OTHER_TESTS: |
Eric Newberry | 69b63dc | 2017-11-04 15:42:46 -0700 | [diff] [blame] | 209 | nfd_objects.source += bld.path.ant_glob('tests/other/fw/*.cpp') |
| 210 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 211 | bld.objects(target='rib-objects', |
| 212 | source=bld.path.ant_glob('rib/**/*.cpp'), |
| 213 | use='core-objects') |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 214 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 215 | bld.program(name='nfd', |
| 216 | target='bin/nfd', |
| 217 | source='daemon/main.cpp', |
| 218 | use='daemon-objects rib-objects') |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 219 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 220 | bld.recurse('tools') |
| 221 | bld.recurse('tests') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 222 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 223 | bld(features='subst', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 224 | source='nfd.conf.sample.in', |
| 225 | target='nfd.conf.sample', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 226 | install_path='${SYSCONFDIR}/ndn', |
| 227 | IF_HAVE_LIBPCAP='' if bld.env.HAVE_LIBPCAP else '; ', |
| 228 | IF_HAVE_WEBSOCKET='' if bld.env.HAVE_WEBSOCKET else '; ') |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 229 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 230 | if bld.env.SPHINX_BUILD: |
| 231 | bld(features='sphinx', |
| 232 | name='manpages', |
| 233 | builder='man', |
| 234 | config='docs/conf.py', |
| 235 | outdir='docs/manpages', |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 236 | source=bld.path.ant_glob('docs/manpages/**/*.rst'), |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 237 | install_path='${MANDIR}', |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 238 | VERSION=VERSION) |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 239 | bld.symlink_as('${MANDIR}/man1/nfdc-channel.1', 'nfdc-face.1') |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 240 | bld.symlink_as('${MANDIR}/man1/nfdc-fib.1', 'nfdc-route.1') |
| 241 | bld.symlink_as('${MANDIR}/man1/nfdc-register.1', 'nfdc-route.1') |
| 242 | bld.symlink_as('${MANDIR}/man1/nfdc-unregister.1', 'nfdc-route.1') |
| 243 | bld.symlink_as('${MANDIR}/man1/nfdc-set-strategy.1', 'nfdc-strategy.1') |
| 244 | bld.symlink_as('${MANDIR}/man1/nfdc-unset-strategy.1', 'nfdc-strategy.1') |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 245 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 246 | bld.install_files('${SYSCONFDIR}/ndn', 'autoconfig.conf.sample') |
Alexander Afanasyev | 5c47597 | 2015-12-20 16:16:56 -0800 | [diff] [blame] | 247 | |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 248 | def docs(bld): |
| 249 | from waflib import Options |
| 250 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 251 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 252 | def doxygen(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 253 | version(bld) |
| 254 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 255 | if not bld.env.DOXYGEN: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 256 | bld.fatal('Cannot build documentation ("doxygen" not found in PATH)') |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 257 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 258 | bld(features='subst', |
| 259 | name='doxygen.conf', |
| 260 | source=['docs/doxygen.conf.in', |
| 261 | 'docs/named_data_theme/named_data_footer-with-analytics.html.in'], |
| 262 | target=['docs/doxygen.conf', |
| 263 | 'docs/named_data_theme/named_data_footer-with-analytics.html'], |
| 264 | VERSION=VERSION, |
| 265 | HTML_FOOTER='../build/docs/named_data_theme/named_data_footer-with-analytics.html' \ |
| 266 | if os.getenv('GOOGLE_ANALYTICS', None) \ |
| 267 | else '../docs/named_data_theme/named_data_footer.html', |
| 268 | GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', '')) |
| 269 | |
| 270 | bld(features='doxygen', |
| 271 | doxyfile='docs/doxygen.conf', |
| 272 | use='doxygen.conf') |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 273 | |
| 274 | def sphinx(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 275 | version(bld) |
| 276 | |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 277 | if not bld.env.SPHINX_BUILD: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 278 | bld.fatal('Cannot build documentation ("sphinx-build" not found in PATH)') |
| 279 | |
| 280 | bld(features='sphinx', |
| 281 | config='docs/conf.py', |
| 282 | outdir='docs', |
| 283 | source=bld.path.ant_glob('docs/**/*.rst'), |
| 284 | VERSION=VERSION) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 285 | |
| 286 | def version(ctx): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 287 | # don't execute more than once |
Alexander Afanasyev | 2618153 | 2014-05-07 23:38:51 -0700 | [diff] [blame] | 288 | if getattr(Context.g_module, 'VERSION_BASE', None): |
| 289 | return |
| 290 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 291 | Context.g_module.VERSION_BASE = Context.g_module.VERSION |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 292 | Context.g_module.VERSION_SPLIT = VERSION_BASE.split('.') |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 293 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 294 | # first, try to get a version string from git |
| 295 | gotVersionFromGit = False |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 296 | try: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 297 | cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX] |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 298 | out = subprocess.check_output(cmd, universal_newlines=True).strip() |
| 299 | if out: |
| 300 | gotVersionFromGit = True |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 301 | if out.startswith(GIT_TAG_PREFIX): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 302 | Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX) |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 303 | else: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 304 | # no tags matched |
| 305 | Context.g_module.VERSION = '%s-commit-%s' % (VERSION_BASE, out) |
| 306 | except subprocess.CalledProcessError: |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 307 | pass |
| 308 | |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 309 | versionFile = ctx.path.find_node('VERSION') |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 310 | if not gotVersionFromGit and versionFile is not None: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 311 | try: |
| 312 | Context.g_module.VERSION = versionFile.read() |
| 313 | return |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 314 | except EnvironmentError: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 315 | pass |
| 316 | |
| 317 | # version was obtained from git, update VERSION file if necessary |
| 318 | if versionFile is not None: |
| 319 | try: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 320 | if versionFile.read() == Context.g_module.VERSION: |
| 321 | # already up-to-date |
| 322 | return |
| 323 | except EnvironmentError as e: |
| 324 | Logs.warn('%s exists but is not readable (%s)' % (versionFile, e.strerror)) |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 325 | else: |
| 326 | versionFile = ctx.path.make_node('VERSION') |
| 327 | |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 328 | try: |
| 329 | versionFile.write(Context.g_module.VERSION) |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 330 | except EnvironmentError as e: |
| 331 | Logs.warn('%s is not writable (%s)' % (versionFile, e.strerror)) |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 332 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 333 | def dist(ctx): |
| 334 | version(ctx) |
| 335 | |
| 336 | def distcheck(ctx): |
| 337 | version(ctx) |