blob: 909a2dfbdc70ed960e6d6299aee5c7536235998a [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Yingdi Yu40cd1c32014-04-17 15:02:17 -07002
3"""
4Copyright (c) 2014 University of Memphis,
5 Regents of the University of California
6
7This file is part of NLSR (Named-data Link State Routing).
8See AUTHORS.md for complete list of NLSR authors and contributors.
9
10NLSR is free software: you can redistribute it and/or modify it under the terms
11of the GNU General Public License as published by the Free Software Foundation,
12either version 3 of the License, or (at your option) any later version.
13
14NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along with
19NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20"""
21
akmhoque05d5fcf2014-04-15 14:58:45 -050022VERSION='1.0'
23NAME="NLSR"
akmhoque298385a2014-02-13 14:13:09 -060024
akmhoque85d88332014-02-17 21:11:21 -060025from waflib import Build, Logs, Utils, Task, TaskGen, Configure
akmhoque05d5fcf2014-04-15 14:58:45 -050026from waflib.Tools import c_preproc
akmhoque298385a2014-02-13 14:13:09 -060027
28def options(opt):
Yingdi Yu40cd1c32014-04-17 15:02:17 -070029 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'])
akmhoque298385a2014-02-13 14:13:09 -060034
Yingdi Yu40cd1c32014-04-17 15:02:17 -070035 nlsropt = opt.add_option_group('NLSR Options')
akmhoque05d5fcf2014-04-15 14:58:45 -050036
Yingdi Yu40cd1c32014-04-17 15:02:17 -070037 nlsropt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
38 help='''build unit tests''')
akmhoque298385a2014-02-13 14:13:09 -060039
akmhoque05d5fcf2014-04-15 14:58:45 -050040
akmhoque298385a2014-02-13 14:13:09 -060041def configure(conf):
Yingdi Yu40cd1c32014-04-17 15:02:17 -070042 conf.load("compiler_cxx gnu_dirs boost openssl")
akmhoque05d5fcf2014-04-15 14:58:45 -050043
Yingdi Yu40cd1c32014-04-17 15:02:17 -070044 conf.load('default-compiler-flags')
akmhoque298385a2014-02-13 14:13:09 -060045
akmhoquec8a10f72014-04-25 18:42:55 -050046 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
Yingdi Yu40cd1c32014-04-17 15:02:17 -070047 uselib_store='NDN_CPP', mandatory=True)
akmhoque85d88332014-02-17 21:11:21 -060048
akmhoque157b0a42014-05-13 00:26:37 -050049 boost_libs = 'system chrono program_options iostreams thread regex'
Yingdi Yu40cd1c32014-04-17 15:02:17 -070050 if conf.options.with_tests:
51 conf.env['WITH_TESTS'] = 1
52 conf.define('WITH_TESTS', 1);
53 boost_libs += ' unit_test_framework'
akmhoque85d88332014-02-17 21:11:21 -060054
Yingdi Yu40cd1c32014-04-17 15:02:17 -070055 conf.check_boost(lib=boost_libs)
akmhoque298385a2014-02-13 14:13:09 -060056
akmhoquec8a10f72014-04-25 18:42:55 -050057 if conf.env.BOOST_VERSION_NUMBER < 104800:
akmhoquefdbddb12014-05-02 18:35:19 -050058 Logs.error("Minimum required boost version is 1.48.0")
Yingdi Yu40cd1c32014-04-17 15:02:17 -070059 Logs.error("Please upgrade your distribution or install custom boost libraries")
akmhoque05d5fcf2014-04-15 14:58:45 -050060 return
61
Yingdi Yu40cd1c32014-04-17 15:02:17 -070062 conf.load('protoc')
akmhoque05d5fcf2014-04-15 14:58:45 -050063
Yingdi Yu40cd1c32014-04-17 15:02:17 -070064 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')
akmhoque05d5fcf2014-04-15 14:58:45 -050069
akmhoque298385a2014-02-13 14:13:09 -060070
71def build (bld):
Yingdi Yu40cd1c32014-04-17 15:02:17 -070072 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',
akmhoque298385a2014-02-13 14:13:09 -060080 )
81
Yingdi Yu40cd1c32014-04-17 15:02:17 -070082 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 )
akmhoque298385a2014-02-13 14:13:09 -060092
Yingdi Yu40cd1c32014-04-17 15:02:17 -070093 nlsr = bld(
94 target='bin/nlsr',
95 features='cxx cxxprogram',
96 source='src/main.cpp',
97 use='nlsr-objects',
98 )
akmhoque298385a2014-02-13 14:13:09 -060099
Yingdi Yu40cd1c32014-04-17 15:02:17 -0700100 if bld.env['WITH_TESTS']:
101 bld.recurse('tests')
102 bld.recurse('tests-integrated')