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 | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 49 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], |
| 50 | uselib_store='LOG4CXX', mandatory=True) |
| 51 | |
| 52 | boost_libs = 'system chrono program_options iostreams thread regex filesystem' |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 53 | if conf.options.with_tests: |
| 54 | conf.env['WITH_TESTS'] = 1 |
| 55 | conf.define('WITH_TESTS', 1); |
| 56 | boost_libs += ' unit_test_framework' |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 57 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 58 | conf.check_boost(lib=boost_libs) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 59 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 60 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 61 | Logs.error("Minimum required boost version is 1.48.0") |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 62 | Logs.error("Please upgrade your distribution or install custom boost libraries") |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 63 | return |
| 64 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 65 | conf.load('protoc') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 66 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 67 | conf.load('coverage') |
| 68 | |
| 69 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nlsr.conf' % conf.env['SYSCONFDIR']) |
| 70 | |
| 71 | conf.write_config_header('config.hpp') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 72 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 73 | |
| 74 | def build (bld): |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 75 | nsync_objects = bld( |
| 76 | target='nsync-objects', |
| 77 | name='nsync-objects', |
| 78 | features='cxx', |
| 79 | source=bld.path.ant_glob(['nsync/**/*.cc', 'nsync/**/*.proto']), |
| 80 | use='BOOST NDN_CPP OPENSSL', |
| 81 | includes='nsync', |
| 82 | export_includes='nsync', |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 83 | ) |
| 84 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 85 | nlsr_objects = bld( |
| 86 | target='nlsr-objects', |
| 87 | name='nlsr-objects', |
| 88 | features='cxx', |
| 89 | source=bld.path.ant_glob(['src/**/*.cpp'], |
| 90 | excl=['src/main.cpp']), |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 91 | use='nsync-objects NDN_CPP BOOST LOG4CXX', |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 92 | includes='. src', |
| 93 | export_includes='. src', |
| 94 | ) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 95 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 96 | nlsr = bld( |
| 97 | target='bin/nlsr', |
| 98 | features='cxx cxxprogram', |
| 99 | source='src/main.cpp', |
| 100 | use='nlsr-objects', |
| 101 | ) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 102 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame] | 103 | if bld.env['WITH_TESTS']: |
| 104 | bld.recurse('tests') |
| 105 | bld.recurse('tests-integrated') |