blob: c0e3934041c756325c0d8909c68736e2e7dd92b0 [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
akmhoque674b0b12014-05-20 14:33:28 -050049 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 Yu40cd1c32014-04-17 15:02:17 -070053 if conf.options.with_tests:
54 conf.env['WITH_TESTS'] = 1
55 conf.define('WITH_TESTS', 1);
56 boost_libs += ' unit_test_framework'
akmhoque85d88332014-02-17 21:11:21 -060057
Yingdi Yu40cd1c32014-04-17 15:02:17 -070058 conf.check_boost(lib=boost_libs)
akmhoque298385a2014-02-13 14:13:09 -060059
akmhoquec8a10f72014-04-25 18:42:55 -050060 if conf.env.BOOST_VERSION_NUMBER < 104800:
akmhoquefdbddb12014-05-02 18:35:19 -050061 Logs.error("Minimum required boost version is 1.48.0")
Yingdi Yu40cd1c32014-04-17 15:02:17 -070062 Logs.error("Please upgrade your distribution or install custom boost libraries")
akmhoque05d5fcf2014-04-15 14:58:45 -050063 return
64
Yingdi Yu40cd1c32014-04-17 15:02:17 -070065 conf.load('protoc')
akmhoque05d5fcf2014-04-15 14:58:45 -050066
Yingdi Yu40cd1c32014-04-17 15:02:17 -070067 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')
akmhoque05d5fcf2014-04-15 14:58:45 -050072
akmhoque298385a2014-02-13 14:13:09 -060073
74def build (bld):
Yingdi Yu40cd1c32014-04-17 15:02:17 -070075 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',
akmhoque298385a2014-02-13 14:13:09 -060083 )
84
Yingdi Yu40cd1c32014-04-17 15:02:17 -070085 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']),
akmhoque674b0b12014-05-20 14:33:28 -050091 use='nsync-objects NDN_CPP BOOST LOG4CXX',
Yingdi Yu40cd1c32014-04-17 15:02:17 -070092 includes='. src',
93 export_includes='. src',
94 )
akmhoque298385a2014-02-13 14:13:09 -060095
Yingdi Yu40cd1c32014-04-17 15:02:17 -070096 nlsr = bld(
97 target='bin/nlsr',
98 features='cxx cxxprogram',
99 source='src/main.cpp',
100 use='nlsr-objects',
101 )
akmhoque298385a2014-02-13 14:13:09 -0600102
Yingdi Yu40cd1c32014-04-17 15:02:17 -0700103 if bld.env['WITH_TESTS']:
104 bld.recurse('tests')
105 bld.recurse('tests-integrated')