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; -*- |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 2 | VERSION='1.0' |
| 3 | NAME="NLSR" |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 4 | |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 5 | from waflib import Build, Logs, Utils, Task, TaskGen, Configure |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 6 | from waflib.Tools import c_preproc |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 7 | |
| 8 | def options(opt): |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 9 | opt.load('compiler_c compiler_cxx gnu_dirs c_osx') |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 10 | opt.load('boost openssl cryptopp', tooldir=['waf-tools']) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 11 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 12 | opt = opt.add_option_group('NLSR Options') |
| 13 | |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 14 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 15 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 16 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 17 | def configure(conf): |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 18 | conf.load("compiler_c compiler_cxx boost gnu_dirs c_osx openssl cryptopp") |
| 19 | |
| 20 | conf.check_openssl() |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 21 | |
| 22 | if conf.options.debug: |
| 23 | conf.define ('_DEBUG', 1) |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 24 | flags = ['-O0', |
| 25 | '-Wall', |
| 26 | # '-Werror', |
| 27 | '-Wno-unused-variable', |
| 28 | '-g3', |
| 29 | '-Wno-unused-private-field', # only clang supports |
| 30 | '-fcolor-diagnostics', # only clang supports |
| 31 | '-Qunused-arguments', # only clang supports |
| 32 | '-Wno-tautological-compare', # suppress warnings from CryptoPP |
| 33 | '-Wno-unused-function', # another annoying warning from CryptoPP |
| 34 | |
| 35 | '-Wno-deprecated-declarations', |
| 36 | ] |
| 37 | |
| 38 | conf.add_supported_cxxflags (cxxflags = flags) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 39 | else: |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 40 | flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations'] |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 41 | conf.add_supported_cxxflags (cxxflags = flags) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 42 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 43 | |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 44 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True) |
akmhoque | 50fda02 | 2014-02-21 17:58:27 -0600 | [diff] [blame] | 45 | conf.check_cfg(package='nsync', args=['--cflags', '--libs'], uselib_store='nsync', mandatory=True) |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 46 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
| 47 | conf.check_cryptopp(path=conf.options.cryptopp_dir, mandatory=True) |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 48 | conf.check_boost(lib='system iostreams thread unit_test_framework log', uselib_store='BOOST', mandatory=True) |
| 49 | if conf.env.BOOST_VERSION_NUMBER < 105400: |
| 50 | Logs.error ("Minimum required boost version is 1.54.0") |
| 51 | Logs.error ("Please upgrade your distribution or install custom boost libraries") |
| 52 | return |
| 53 | |
| 54 | |
| 55 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 56 | |
| 57 | def build (bld): |
| 58 | bld ( |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 59 | features=['cxx', 'cxxprogram'], |
| 60 | target="nlsr", |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 61 | source = bld.path.ant_glob('src/**/*.cpp'), |
| 62 | use = 'NDN_CPP BOOST CRYPTOPP SQLITE3 nsync', |
| 63 | includes = ". src" |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 64 | ) |
akmhoque | eb764c5 | 2014-03-11 16:01:09 -0500 | [diff] [blame] | 65 | bld.recurse("CertTool") |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 66 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 67 | @Configure.conf |
| 68 | def add_supported_cxxflags(self, cxxflags): |
| 69 | """ |
| 70 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 71 | """ |
| 72 | self.start_msg('Checking allowed flags for c++ compiler') |
| 73 | |
| 74 | supportedFlags = [] |
| 75 | for flag in cxxflags: |
| 76 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 77 | supportedFlags += [flag] |
| 78 | |
| 79 | self.end_msg (' '.join (supportedFlags)) |
| 80 | self.env.CXXFLAGS += supportedFlags |