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