akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 2 | |
| 3 | """ |
| 4 | Copyright (c) 2014 University of Memphis, |
| 5 | Regents of the University of California |
| 6 | |
| 7 | This file is part of NLSR (Named-data Link State Routing). |
| 8 | See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | |
| 10 | NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | of the GNU General Public License as published by the Free Software Foundation, |
| 12 | either version 3 of the License, or (at your option) any later version. |
| 13 | |
| 14 | NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | PURPOSE. See the GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License along with |
| 19 | NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
| 21 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 22 | VERSION='1.0' |
| 23 | NAME="NLSR" |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 24 | |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 25 | from waflib import Build, Logs, Utils, Task, TaskGen, Configure |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 26 | from waflib.Tools import c_preproc |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 27 | |
| 28 | def options(opt): |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 29 | opt.load(['compiler_cxx', 'gnu_dirs']) |
| 30 | opt.load(['default-compiler-flags', 'coverage', |
| 31 | 'boost', 'protoc', 'openssl', |
| 32 | 'doxygen', 'sphinx_build'], |
| 33 | tooldir=['.waf-tools']) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 34 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 35 | nlsropt = opt.add_option_group('NLSR Options') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 36 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 37 | nlsropt.add_option('--with-tests', action='store_true', default=False, dest='with_tests', |
| 38 | help='''build unit tests''') |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 39 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 40 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 41 | def configure(conf): |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 42 | conf.load("compiler_cxx gnu_dirs boost openssl") |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 43 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 44 | conf.load('default-compiler-flags') |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 45 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 46 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 47 | uselib_store='NDN_CPP', mandatory=True) |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 48 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 49 | boost_libs = 'system chrono program_options iostreams thread regex' |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 50 | if conf.options.with_tests: |
| 51 | conf.env['WITH_TESTS'] = 1 |
| 52 | conf.define('WITH_TESTS', 1); |
| 53 | boost_libs += ' unit_test_framework' |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 54 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 55 | conf.check_boost(lib=boost_libs) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 56 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 57 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 58 | Logs.error("Minimum required boost version is 1.48.0") |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 59 | Logs.error("Please upgrade your distribution or install custom boost libraries") |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 60 | return |
| 61 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 62 | conf.load('protoc') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 63 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 64 | conf.load('coverage') |
| 65 | |
| 66 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nlsr.conf' % conf.env['SYSCONFDIR']) |
| 67 | |
| 68 | conf.write_config_header('config.hpp') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 69 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 70 | |
| 71 | def build (bld): |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 72 | nsync_objects = bld( |
| 73 | target='nsync-objects', |
| 74 | name='nsync-objects', |
| 75 | features='cxx', |
| 76 | source=bld.path.ant_glob(['nsync/**/*.cc', 'nsync/**/*.proto']), |
| 77 | use='BOOST NDN_CPP OPENSSL', |
| 78 | includes='nsync', |
| 79 | export_includes='nsync', |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 80 | ) |
| 81 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 82 | nlsr_objects = bld( |
| 83 | target='nlsr-objects', |
| 84 | name='nlsr-objects', |
| 85 | features='cxx', |
| 86 | source=bld.path.ant_glob(['src/**/*.cpp'], |
| 87 | excl=['src/main.cpp']), |
| 88 | use='nsync-objects NDN_CPP BOOST', |
| 89 | includes='. src', |
| 90 | export_includes='. src', |
| 91 | ) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 92 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 93 | nlsr = bld( |
| 94 | target='bin/nlsr', |
| 95 | features='cxx cxxprogram', |
| 96 | source='src/main.cpp', |
| 97 | use='nlsr-objects', |
| 98 | ) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 99 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 100 | if bld.env['WITH_TESTS']: |
| 101 | bld.recurse('tests') |
| 102 | bld.recurse('tests-integrated') |