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 | |
| 3 | """ |
Alexander Afanasyev | 19e2e6d | 2017-01-20 20:21:36 -0800 | [diff] [blame] | 4 | Copyright (c) 2014-2017, Regents of the University of California, |
taylorchu | 5ae2877 | 2015-03-08 17:45:52 -0700 | [diff] [blame] | 5 | Arizona Board of Regents, |
| 6 | Colorado State University, |
| 7 | University Pierre & Marie Curie, Sorbonne University, |
| 8 | Washington University in St. Louis, |
| 9 | Beijing Institute of Technology, |
| 10 | The University of Memphis. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 11 | |
| 12 | This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 13 | See AUTHORS.md for complete list of NFD authors and contributors. |
| 14 | |
| 15 | NFD is free software: you can redistribute it and/or modify it under the terms |
| 16 | of the GNU General Public License as published by the Free Software Foundation, |
| 17 | either version 3 of the License, or (at your option) any later version. |
| 18 | |
| 19 | NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 20 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 21 | PURPOSE. See the GNU General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License along with |
| 24 | NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 25 | """ |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 26 | |
Alexander Afanasyev | 19e2e6d | 2017-01-20 20:21:36 -0800 | [diff] [blame] | 27 | VERSION = "0.5.1" |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 28 | APPNAME = "nfd" |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 29 | BUGREPORT = "https://redmine.named-data.net/projects/nfd" |
| 30 | URL = "https://named-data.net/doc/NFD/" |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 31 | GIT_TAG_PREFIX = "NFD-" |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 32 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 33 | from waflib import Logs, Utils, Context |
Alexander Afanasyev | 2075788 | 2014-08-25 22:39:08 -0700 | [diff] [blame] | 34 | import os |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 35 | |
| 36 | def options(opt): |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 37 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 38 | opt.load(['default-compiler-flags', 'compiler-features', 'type_traits', |
| 39 | 'coverage', 'pch', 'sanitizers', 'boost', 'boost-kqueue', |
| 40 | 'dependency-checker', 'unix-socket', 'websocket', |
| 41 | 'doxygen', 'sphinx_build'], |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 42 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 43 | |
| 44 | nfdopt = opt.add_option_group('NFD Options') |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 45 | opt.addUnixOptions(nfdopt) |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 46 | opt.addWebsocketOptions(nfdopt) |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 47 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 48 | opt.addDependencyOptions(nfdopt, 'libpcap') |
| 49 | nfdopt.add_option('--without-libpcap', action='store_true', default=False, |
| 50 | dest='without_libpcap', |
| 51 | help='''Disable libpcap (Ethernet face support will be disabled)''') |
| 52 | |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 53 | opt.addDependencyOptions(nfdopt, 'librt', '(optional)') |
| 54 | opt.addDependencyOptions(nfdopt, 'libresolv', '(optional)') |
| 55 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 56 | nfdopt.add_option('--with-tests', action='store_true', default=False, |
| 57 | dest='with_tests', help='''Build unit tests''') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 58 | nfdopt.add_option('--with-other-tests', action='store_true', default=False, |
| 59 | dest='with_other_tests', help='''Build other tests''') |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 60 | |
Alexander Afanasyev | 8269a05 | 2015-02-09 16:25:36 -0800 | [diff] [blame] | 61 | nfdopt.add_option('--with-custom-logger', type='string', default=None, |
| 62 | dest='with_custom_logger', |
| 63 | help='''Path to custom-logger.hpp and custom-logger-factory.hpp ''' |
| 64 | '''implementing Logger and LoggerFactory interfaces''') |
| 65 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 66 | def configure(conf): |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 67 | conf.load(['compiler_cxx', 'gnu_dirs', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 68 | 'default-compiler-flags', 'compiler-features', 'type_traits', |
Eric Newberry | 27bdd1a | 2016-11-01 18:02:54 -0700 | [diff] [blame] | 69 | 'pch', 'boost', 'boost-kqueue', 'dependency-checker', 'websocket', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 70 | 'doxygen', 'sphinx_build']) |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 71 | |
Davide Pesavento | f0ae442 | 2014-05-05 16:32:12 +0200 | [diff] [blame] | 72 | conf.find_program('bash', var='BASH') |
| 73 | |
taylorchu | 5ae2877 | 2015-03-08 17:45:52 -0700 | [diff] [blame] | 74 | if 'PKG_CONFIG_PATH' not in os.environ: |
Alexander Afanasyev | cdb8f36 | 2015-03-30 10:52:54 -0700 | [diff] [blame] | 75 | os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env) |
Alexander Afanasyev | 4a77136 | 2014-04-24 21:29:33 -0700 | [diff] [blame] | 76 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 77 | uselib_store='NDN_CXX', mandatory=True) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 78 | |
Davide Pesavento | b499a60 | 2014-11-18 22:36:56 +0100 | [diff] [blame] | 79 | conf.checkDependency(name='librt', lib='rt', mandatory=False) |
| 80 | conf.checkDependency(name='libresolv', lib='resolv', mandatory=False) |
| 81 | |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 82 | if not conf.check_cxx(msg='Checking if privilege drop/elevation is supported', mandatory=False, |
| 83 | define_name='HAVE_PRIVILEGE_DROP_AND_ELEVATE', fragment=''' |
| 84 | #include <unistd.h> |
| 85 | #include <pwd.h> |
| 86 | #include <grp.h> |
| 87 | int |
| 88 | main(int, char**) |
| 89 | { |
Alexander Afanasyev | e0d71b0 | 2016-05-25 11:39:13 -0700 | [diff] [blame] | 90 | char buffer[100]; |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 91 | ::sysconf(_SC_GETGR_R_SIZE_MAX); |
| 92 | group grp; |
Alexander Afanasyev | e0d71b0 | 2016-05-25 11:39:13 -0700 | [diff] [blame] | 93 | group* grpRes; |
| 94 | getgrnam_r("nogroup", &grp, buffer, 100, &grpRes); |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 95 | passwd pwd; |
Alexander Afanasyev | e0d71b0 | 2016-05-25 11:39:13 -0700 | [diff] [blame] | 96 | passwd* pwdRes; |
| 97 | getpwnam_r("nobody", &pwd, buffer, 100, &pwdRes); |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 98 | |
| 99 | int ret = setegid(grp.gr_gid); |
| 100 | ret = seteuid(pwd.pw_uid); |
| 101 | (void)(ret); |
Weiwei Liu | f5aee94 | 2016-03-19 07:00:42 +0000 | [diff] [blame] | 102 | |
| 103 | getegid(); |
| 104 | geteuid(); |
Alexander Afanasyev | 748e989 | 2015-01-28 15:07:41 -0800 | [diff] [blame] | 105 | return 0; |
| 106 | } |
| 107 | '''): |
| 108 | Logs.warn('Dropping privileges is not supported on this platform') |
| 109 | |
Alexander Afanasyev | 49343f6 | 2015-01-26 21:58:07 -0800 | [diff] [blame] | 110 | conf.check_cxx(header_name='ifaddrs.h', mandatory=False) |
Davide Pesavento | aaa5dd3 | 2016-09-02 12:33:33 +0000 | [diff] [blame] | 111 | 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] | 112 | |
Davide Pesavento | 5f47aa6 | 2016-10-07 22:09:09 +0200 | [diff] [blame] | 113 | boost_libs = 'system chrono program_options thread log log_setup' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 114 | if conf.options.with_tests: |
| 115 | conf.env['WITH_TESTS'] = 1 |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 116 | conf.define('WITH_TESTS', 1) |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 117 | boost_libs += ' unit_test_framework' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 118 | |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 119 | if conf.options.with_other_tests: |
| 120 | conf.env['WITH_OTHER_TESTS'] = 1 |
| 121 | |
Yumin Xia | ab49745 | 2016-05-10 20:23:24 +0800 | [diff] [blame] | 122 | conf.check_boost(lib=boost_libs, mt=True) |
Davide Pesavento | cafae24 | 2016-04-22 02:21:35 +0200 | [diff] [blame] | 123 | if conf.env.BOOST_VERSION_NUMBER < 105400: |
| 124 | Logs.error("Minimum required boost version is 1.54.0") |
Junxiao Shi | ea48d8b | 2014-03-16 13:53:47 -0700 | [diff] [blame] | 125 | Logs.error("Please upgrade your distribution or install custom boost libraries" + |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 126 | " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 127 | return |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 128 | |
Alexander Afanasyev | 6602b3b | 2016-03-15 14:14:11 -0700 | [diff] [blame] | 129 | 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] | 130 | 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] | 131 | 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] | 132 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 133 | conf.load('unix-socket') |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 134 | conf.checkWebsocket(mandatory=True) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 135 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 136 | if not conf.options.without_libpcap: |
Alexander Afanasyev | e918621 | 2014-08-23 20:15:48 -0700 | [diff] [blame] | 137 | conf.check_asio_pcap_support() |
| 138 | if conf.env['HAVE_ASIO_PCAP_SUPPORT']: |
| 139 | conf.checkDependency(name='libpcap', lib='pcap', mandatory=True, |
| 140 | errmsg='not found, but required for Ethernet face support. ' |
| 141 | 'Specify --without-libpcap to disable Ethernet face support.') |
| 142 | else: |
| 143 | Logs.warn('Warning: Ethernet face support is not supported on this platform with Boost libraries version 1.56. ' |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 144 | 'See https://redmine.named-data.net/issues/1877 for more details') |
Davide Pesavento | f0ae442 | 2014-05-05 16:32:12 +0200 | [diff] [blame] | 145 | if conf.env['HAVE_LIBPCAP']: |
| 146 | conf.check_cxx(function_name='pcap_set_immediate_mode', header_name='pcap/pcap.h', |
| 147 | cxxflags='-Wno-error', use='LIBPCAP', mandatory=False) |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 148 | |
Alexander Afanasyev | 8269a05 | 2015-02-09 16:25:36 -0800 | [diff] [blame] | 149 | if conf.options.with_custom_logger: |
| 150 | conf.define('HAVE_CUSTOM_LOGGER', 1) |
| 151 | conf.env['INCLUDES_CUSTOM_LOGGER'] = [conf.options.with_custom_logger] |
| 152 | conf.env['HAVE_CUSTOM_LOGGER'] = 1 |
| 153 | |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 154 | conf.load('coverage') |
| 155 | |
Eric Newberry | 27bdd1a | 2016-11-01 18:02:54 -0700 | [diff] [blame] | 156 | conf.load('sanitizers') |
| 157 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 158 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env['SYSCONFDIR']) |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 159 | |
Junxiao Shi | 759f706 | 2014-11-29 10:19:22 -0700 | [diff] [blame] | 160 | # disable assertions in release builds |
| 161 | if not conf.options.debug: |
| 162 | conf.define('NDEBUG', 1) |
| 163 | |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 164 | conf.write_config_header('core/config.hpp') |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 165 | |
Junxiao Shi | 09bf7c4 | 2014-01-31 11:10:25 -0700 | [diff] [blame] | 166 | def build(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 167 | version(bld) |
| 168 | |
| 169 | bld(features="subst", |
| 170 | name='version', |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 171 | source='core/version.hpp.in', |
| 172 | target='core/version.hpp', |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 173 | install_path=None, |
| 174 | VERSION_STRING=VERSION_BASE, |
| 175 | VERSION_BUILD=VERSION, |
| 176 | VERSION=int(VERSION_SPLIT[0]) * 1000000 + |
| 177 | int(VERSION_SPLIT[1]) * 1000 + |
| 178 | int(VERSION_SPLIT[2]), |
| 179 | VERSION_MAJOR=VERSION_SPLIT[0], |
| 180 | VERSION_MINOR=VERSION_SPLIT[1], |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 181 | VERSION_PATCH=VERSION_SPLIT[2]) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 182 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 183 | core = bld( |
| 184 | target='core-objects', |
| 185 | name='core-objects', |
Alexander Afanasyev | 58ea458 | 2014-05-30 08:38:56 +0300 | [diff] [blame] | 186 | features='cxx pch', |
Alexander Afanasyev | 8269a05 | 2015-02-09 16:25:36 -0800 | [diff] [blame] | 187 | source=bld.path.ant_glob(['core/**/*.cpp'], |
| 188 | excl=['core/logger*.cpp']), |
Alexander Afanasyev | 3d1874a | 2016-06-15 12:25:01 -0700 | [diff] [blame] | 189 | use='version NDN_CXX BOOST LIBRT', |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 190 | includes='. core', |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 191 | export_includes='.', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 192 | headers='core/common.hpp') |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 193 | |
Alexander Afanasyev | 8269a05 | 2015-02-09 16:25:36 -0800 | [diff] [blame] | 194 | if bld.env['HAVE_CUSTOM_LOGGER']: |
| 195 | core.use += " CUSTOM_LOGGER" |
| 196 | else: |
| 197 | core.source += bld.path.ant_glob(['core/logger*.cpp']) |
| 198 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 199 | nfd_objects = bld( |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 200 | target='daemon-objects', |
| 201 | name='daemon-objects', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 202 | features='cxx', |
| 203 | source=bld.path.ant_glob(['daemon/**/*.cpp'], |
| 204 | excl=['daemon/face/ethernet-*.cpp', |
| 205 | 'daemon/face/unix-*.cpp', |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 206 | 'daemon/face/websocket-*.cpp', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 207 | 'daemon/main.cpp']), |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 208 | use='core-objects WEBSOCKET', |
| 209 | includes='daemon', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 210 | export_includes='daemon') |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 211 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 212 | if bld.env['HAVE_LIBPCAP']: |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 213 | nfd_objects.source += bld.path.ant_glob('daemon/face/ethernet-*.cpp') |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 214 | nfd_objects.use += ' LIBPCAP' |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 215 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 216 | if bld.env['HAVE_UNIX_SOCKETS']: |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 217 | nfd_objects.source += bld.path.ant_glob('daemon/face/unix-*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 218 | |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 219 | if bld.env['HAVE_WEBSOCKET']: |
| 220 | nfd_objects.source += bld.path.ant_glob('daemon/face/websocket-*.cpp') |
| 221 | |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 222 | rib_objects = bld( |
| 223 | target='rib-objects', |
| 224 | name='rib-objects', |
| 225 | features='cxx', |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 226 | source=bld.path.ant_glob(['rib/**/*.cpp']), |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 227 | use='core-objects') |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 228 | |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 229 | bld(target='bin/nfd', |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 230 | features='cxx cxxprogram', |
Alexander Afanasyev | f08a737 | 2015-02-09 21:28:19 -0800 | [diff] [blame] | 231 | source='daemon/main.cpp', |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 232 | use='daemon-objects rib-objects') |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 233 | |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 234 | bld.recurse("tools") |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 235 | bld.recurse("tests") |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 236 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 237 | bld(features="subst", |
| 238 | source='nfd.conf.sample.in', |
| 239 | target='nfd.conf.sample', |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame] | 240 | install_path="${SYSCONFDIR}/ndn", |
Wentao Shang | 53df163 | 2014-04-21 12:01:32 -0700 | [diff] [blame] | 241 | IF_HAVE_LIBPCAP="" if bld.env['HAVE_LIBPCAP'] else "; ", |
| 242 | IF_HAVE_WEBSOCKET="" if bld.env['HAVE_WEBSOCKET'] else "; ") |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 243 | |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 244 | if bld.env['SPHINX_BUILD']: |
| 245 | bld(features="sphinx", |
| 246 | builder="man", |
| 247 | outdir="docs/manpages", |
| 248 | config="docs/conf.py", |
| 249 | source=bld.path.ant_glob('docs/manpages/**/*.rst'), |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 250 | install_path="${MANDIR}/", |
| 251 | VERSION=VERSION) |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 252 | bld.symlink_as('${MANDIR}/man1/nfdc-channel.1', 'nfdc-face.1') |
Junxiao Shi | 6c13562 | 2016-11-21 14:30:33 +0000 | [diff] [blame] | 253 | bld.symlink_as('${MANDIR}/man1/nfdc-fib.1', 'nfdc-route.1') |
| 254 | bld.symlink_as('${MANDIR}/man1/nfdc-register.1', 'nfdc-route.1') |
| 255 | bld.symlink_as('${MANDIR}/man1/nfdc-unregister.1', 'nfdc-route.1') |
| 256 | bld.symlink_as('${MANDIR}/man1/nfdc-set-strategy.1', 'nfdc-strategy.1') |
| 257 | bld.symlink_as('${MANDIR}/man1/nfdc-unset-strategy.1', 'nfdc-strategy.1') |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 258 | |
Alexander Afanasyev | 5c47597 | 2015-12-20 16:16:56 -0800 | [diff] [blame] | 259 | bld.install_files("${SYSCONFDIR}/ndn", "autoconfig.conf.sample") |
| 260 | |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 261 | def docs(bld): |
| 262 | from waflib import Options |
| 263 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 264 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 265 | def doxygen(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 266 | version(bld) |
| 267 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 268 | if not bld.env.DOXYGEN: |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 269 | Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
| 270 | else: |
| 271 | bld(features="subst", |
| 272 | name="doxygen-conf", |
Alexander Afanasyev | 2075788 | 2014-08-25 22:39:08 -0700 | [diff] [blame] | 273 | source=["docs/doxygen.conf.in", |
| 274 | "docs/named_data_theme/named_data_footer-with-analytics.html.in"], |
| 275 | target=["docs/doxygen.conf", |
| 276 | "docs/named_data_theme/named_data_footer-with-analytics.html"], |
Alexander Afanasyev | abb307c | 2015-10-23 17:00:13 -0700 | [diff] [blame] | 277 | VERSION=VERSION, |
Alexander Afanasyev | 2075788 | 2014-08-25 22:39:08 -0700 | [diff] [blame] | 278 | HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \ |
| 279 | if os.getenv('GOOGLE_ANALYTICS', None) \ |
| 280 | else "../docs/named_data_theme/named_data_footer.html", |
Davide Pesavento | 67f3027 | 2016-08-10 01:55:16 +0000 | [diff] [blame] | 281 | GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', "")) |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 282 | |
| 283 | bld(features="doxygen", |
| 284 | doxyfile='docs/doxygen.conf', |
| 285 | use="doxygen-conf") |
Alexander Afanasyev | 49272f7 | 2014-04-06 21:49:46 -0700 | [diff] [blame] | 286 | |
| 287 | def sphinx(bld): |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 288 | version(bld) |
| 289 | |
Beichuan Zhang | 55b8ed4 | 2014-04-26 22:25:44 -0700 | [diff] [blame] | 290 | if not bld.env.SPHINX_BUILD: |
| 291 | bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)") |
| 292 | else: |
| 293 | bld(features="sphinx", |
| 294 | outdir="docs", |
| 295 | source=bld.path.ant_glob('docs/**/*.rst'), |
| 296 | config="docs/conf.py", |
Alexander Afanasyev | abb307c | 2015-10-23 17:00:13 -0700 | [diff] [blame] | 297 | VERSION=VERSION) |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 298 | |
| 299 | def version(ctx): |
Alexander Afanasyev | 2618153 | 2014-05-07 23:38:51 -0700 | [diff] [blame] | 300 | if getattr(Context.g_module, 'VERSION_BASE', None): |
| 301 | return |
| 302 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 303 | Context.g_module.VERSION_BASE = Context.g_module.VERSION |
| 304 | Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')] |
| 305 | |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 306 | didGetVersion = False |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 307 | try: |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 308 | cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX] |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 309 | p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE, |
| 310 | stderr=None, stdin=None) |
Alexander Afanasyev | 3b21fa3 | 2014-09-01 13:25:20 -0700 | [diff] [blame] | 311 | out = str(p.communicate()[0].strip()) |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 312 | didGetVersion = (p.returncode == 0 and out != "") |
| 313 | if didGetVersion: |
| 314 | if out.startswith(GIT_TAG_PREFIX): |
| 315 | Context.g_module.VERSION = out[len(GIT_TAG_PREFIX):] |
| 316 | else: |
| 317 | Context.g_module.VERSION = "%s-commit-%s" % (Context.g_module.VERSION_BASE, out) |
| 318 | except OSError: |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 319 | pass |
| 320 | |
Alexander Afanasyev | 48f5a3c | 2014-08-22 22:33:01 -0700 | [diff] [blame] | 321 | versionFile = ctx.path.find_node('VERSION') |
| 322 | |
| 323 | if not didGetVersion and versionFile is not None: |
| 324 | try: |
| 325 | Context.g_module.VERSION = versionFile.read() |
| 326 | return |
| 327 | except (OSError, IOError): |
| 328 | pass |
| 329 | |
| 330 | # version was obtained from git, update VERSION file if necessary |
| 331 | if versionFile is not None: |
| 332 | try: |
| 333 | version = versionFile.read() |
| 334 | if version == Context.g_module.VERSION: |
| 335 | return # no need to update |
| 336 | except (OSError, IOError): |
| 337 | Logs.warn("VERSION file exists, but not readable") |
| 338 | else: |
| 339 | versionFile = ctx.path.make_node('VERSION') |
| 340 | |
| 341 | if versionFile is None: |
| 342 | return |
| 343 | |
| 344 | try: |
| 345 | versionFile.write(Context.g_module.VERSION) |
| 346 | except (OSError, IOError): |
| 347 | Logs.warn("VERSION file is not writeable") |
| 348 | |
Alexander Afanasyev | b47d538 | 2014-05-05 14:35:03 -0700 | [diff] [blame] | 349 | def dist(ctx): |
| 350 | version(ctx) |
| 351 | |
| 352 | def distcheck(ctx): |
| 353 | version(ctx) |