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; -*- |
| 2 | |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 3 | from waflib import Build, Logs, Utils, Task, TaskGen, Configure |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 4 | |
| 5 | def options(opt): |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 6 | opt.load('compiler_c compiler_cxx gnu_dirs c_osx') |
akmhoque | 3f4c7b0 | 2014-02-17 21:13:07 -0600 | [diff] [blame] | 7 | opt.load('boost', tooldir=['waf-tools']) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 8 | |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 9 | opt = opt.add_option_group('Options') |
| 10 | 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] | 11 | |
| 12 | def configure(conf): |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 13 | conf.load("compiler_cxx boost gnu_dirs") |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 14 | |
| 15 | if conf.options.debug: |
| 16 | conf.define ('_DEBUG', 1) |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 17 | flags = ['-O0', |
| 18 | '-Wall', |
| 19 | # '-Werror', |
| 20 | '-Wno-unused-variable', |
| 21 | '-g3', |
| 22 | '-Wno-unused-private-field', # only clang supports |
| 23 | '-fcolor-diagnostics', # only clang supports |
| 24 | '-Qunused-arguments', # only clang supports |
| 25 | '-Wno-tautological-compare', # suppress warnings from CryptoPP |
| 26 | '-Wno-unused-function', # another annoying warning from CryptoPP |
| 27 | |
| 28 | '-Wno-deprecated-declarations', |
| 29 | ] |
| 30 | |
| 31 | conf.add_supported_cxxflags (cxxflags = flags) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 32 | else: |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 33 | flags = ['-O3', '-g', '-Wno-tautological-compare','-Wno-unused-variable', |
| 34 | '-Wno-unused-function', '-Wno-deprecated-declarations'] |
| 35 | conf.add_supported_cxxflags (cxxflags = flags) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 36 | |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 37 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True) |
| 38 | conf.check_boost(lib='system iostreams thread unit_test_framework log', uselib_store='BOOST', version='1_55', mandatory=True) |
akmhoque | 50fda02 | 2014-02-21 17:58:27 -0600 | [diff] [blame^] | 39 | conf.check_cfg(package='nsync', args=['--cflags', '--libs'], uselib_store='nsync', mandatory=True) |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 40 | |
| 41 | def build (bld): |
| 42 | bld ( |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 43 | features=['cxx', 'cxxprogram'], |
| 44 | target="nlsr", |
A K M Mahmudul Hoque | 4e27b94 | 2014-02-20 17:09:51 -0600 | [diff] [blame] | 45 | source = bld.path.ant_glob('src/*.cpp'), |
akmhoque | 50fda02 | 2014-02-21 17:58:27 -0600 | [diff] [blame^] | 46 | use = 'NDN_CPP BOOST nsync', |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 47 | ) |
| 48 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 49 | @Configure.conf |
| 50 | def add_supported_cxxflags(self, cxxflags): |
| 51 | """ |
| 52 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 53 | """ |
| 54 | self.start_msg('Checking allowed flags for c++ compiler') |
| 55 | |
| 56 | supportedFlags = [] |
| 57 | for flag in cxxflags: |
| 58 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 59 | supportedFlags += [flag] |
| 60 | |
| 61 | self.end_msg (' '.join (supportedFlags)) |
| 62 | self.env.CXXFLAGS += supportedFlags |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 63 | |