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 | """ |
| 4 | Copyright (c) 2014 Regents of the University of California, |
| 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 | |
| 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 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 26 | VERSION = '0.1.0' |
| 27 | APPNAME = "nfd" |
| 28 | BUGREPORT = "http://redmine.named-data.net/projects/nfd" |
| 29 | URL = "https://github.com/named-data/NFD" |
| 30 | |
| 31 | from waflib import Logs |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 32 | import os |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 33 | |
| 34 | def options(opt): |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 35 | opt.load('compiler_cxx gnu_dirs') |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 36 | opt.load('boost doxygen coverage unix-socket default-compiler-flags', |
| 37 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 38 | |
| 39 | nfdopt = opt.add_option_group('NFD Options') |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 40 | nfdopt.add_option('--with-tests', action='store_true', default=False, |
| 41 | dest='with_tests', help='''Build unit tests''') |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame^] | 42 | nfdopt.add_option('--with-other-tests', action='store_true', default=False, |
| 43 | dest='with_other_tests', help='''Build other tests''') |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 44 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 45 | def configure(conf): |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 46 | conf.load("compiler_cxx boost gnu_dirs") |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 47 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 48 | try: conf.load("doxygen") |
| 49 | except: pass |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 50 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 51 | conf.load('default-compiler-flags') |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 52 | |
| 53 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], |
| 54 | uselib_store='NDN_CPP', mandatory=True) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 55 | |
Alexander Afanasyev | 82afa1a | 2014-03-20 16:56:56 -0700 | [diff] [blame] | 56 | boost_libs = 'system chrono program_options' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 57 | if conf.options.with_tests: |
| 58 | conf.env['WITH_TESTS'] = 1 |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 59 | conf.define('WITH_TESTS', 1); |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 60 | boost_libs += ' unit_test_framework' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 61 | |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame^] | 62 | if conf.options.with_other_tests: |
| 63 | conf.env['WITH_OTHER_TESTS'] = 1 |
| 64 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 65 | conf.check_boost(lib=boost_libs) |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 66 | |
Alexander Afanasyev | e1724c4 | 2014-02-26 22:00:54 -0800 | [diff] [blame] | 67 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
Junxiao Shi | ea48d8b | 2014-03-16 13:53:47 -0700 | [diff] [blame] | 68 | Logs.error("Minimum required boost version is 1.48.0") |
| 69 | Logs.error("Please upgrade your distribution or install custom boost libraries" + |
| 70 | " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 71 | return |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 72 | |
| 73 | conf.load('unix-socket') |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 74 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 75 | conf.check_cxx(lib='rt', uselib_store='RT', |
| 76 | define_name='HAVE_RT', mandatory=False) |
| 77 | |
| 78 | if conf.check_cxx(lib='pcap', uselib_store='PCAP', |
| 79 | define_name='HAVE_PCAP', mandatory=False): |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 80 | conf.env['HAVE_PCAP'] = True |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 81 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 82 | conf.check_cxx(lib='resolv', uselib_store='RESOLV', mandatory=False) |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 83 | |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 84 | conf.load('coverage') |
| 85 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 86 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env['SYSCONFDIR']) |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 87 | |
Junxiao Shi | 61c5ef3 | 2014-01-24 20:59:30 -0700 | [diff] [blame] | 88 | conf.write_config_header('daemon/config.hpp') |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 89 | |
Junxiao Shi | 09bf7c4 | 2014-01-31 11:10:25 -0700 | [diff] [blame] | 90 | def build(bld): |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 91 | nfd_objects = bld( |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 92 | target='nfd-objects', |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame^] | 93 | name='nfd-objects', |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 94 | features='cxx', |
| 95 | source=bld.path.ant_glob(['daemon/**/*.cpp'], |
| 96 | excl=['daemon/face/ethernet-*.cpp', |
| 97 | 'daemon/face/unix-*.cpp', |
| 98 | 'daemon/main.cpp']), |
| 99 | use='BOOST NDN_CPP RT', |
| 100 | includes='. daemon', |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 101 | ) |
| 102 | |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 103 | if bld.env['HAVE_PCAP']: |
| 104 | nfd_objects.source += bld.path.ant_glob('daemon/face/ethernet-*.cpp') |
| 105 | nfd_objects.use += ' PCAP' |
| 106 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 107 | if bld.env['HAVE_UNIX_SOCKETS']: |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 108 | nfd_objects.source += bld.path.ant_glob('daemon/face/unix-*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 109 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 110 | bld(target='nfd', |
| 111 | features='cxx cxxprogram', |
| 112 | source='daemon/main.cpp', |
| 113 | use='nfd-objects', |
| 114 | includes='. daemon', |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 115 | ) |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 116 | |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 117 | for app in bld.path.ant_glob('tools/*.cpp'): |
| 118 | bld(features=['cxx', 'cxxprogram'], |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 119 | target='bin/%s' % (str(app.change_ext(''))), |
| 120 | source=['tools/%s' % (str(app))], |
| 121 | includes='. daemon', |
| 122 | use='nfd-objects RESOLV', |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 123 | ) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 124 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 125 | # Unit tests |
| 126 | if bld.env['WITH_TESTS']: |
Junxiao Shi | ea48d8b | 2014-03-16 13:53:47 -0700 | [diff] [blame] | 127 | unit_tests = bld.program( |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 128 | target='unit-tests', |
| 129 | features='cxx cxxprogram', |
| 130 | source=bld.path.ant_glob(['tests/**/*.cpp'], |
| 131 | excl=['tests/face/ethernet.cpp', |
| 132 | 'tests/face/unix-*.cpp']), |
| 133 | use='nfd-objects', |
| 134 | includes='. daemon', |
| 135 | install_prefix=None, |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 136 | ) |
| 137 | |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 138 | if bld.env['HAVE_PCAP']: |
| 139 | unit_tests.source += bld.path.ant_glob('tests/face/ethernet.cpp') |
| 140 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 141 | if bld.env['HAVE_UNIX_SOCKETS']: |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 142 | unit_tests.source += bld.path.ant_glob('tests/face/unix-*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 143 | |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame^] | 144 | if bld.env['WITH_OTHER_TESTS']: |
| 145 | bld.recurse("tests-other") |
| 146 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 147 | bld(features="subst", |
| 148 | source='nfd.conf.sample.in', |
| 149 | target='nfd.conf.sample', |
| 150 | install_path="${SYSCONFDIR}/ndn") |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 151 | |
Chengyu Fan | b07788a | 2014-03-31 12:15:36 -0600 | [diff] [blame] | 152 | bld(features='subst', |
| 153 | source='tools/nfd-status-http-server.py', |
| 154 | target='nfd-status-http-server', |
| 155 | install_path="${BINDIR}", |
| 156 | chmod=0755) |
| 157 | |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 158 | def doxygen(bld): |
| 159 | if not bld.env.DOXYGEN: |
| 160 | bld.fatal("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
| 161 | bld(features="doxygen", |
| 162 | doxyfile='docs/doxygen.conf') |