akmhoque | fcf765d | 2014-02-01 23:46:17 -0600 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | from waflib import Build, Logs, Utils, Task, TaskGen, Configure |
| 4 | |
| 5 | def options(opt): |
| 6 | opt.load('compiler_c compiler_cxx gnu_dirs c_osx') |
| 7 | opt.load('boost', tooldir=['.waf-tools']) |
| 8 | |
| 9 | opt = opt.add_option_group('Options') |
| 10 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
| 11 | |
| 12 | def configure(conf): |
| 13 | conf.load("compiler_cxx boost gnu_dirs") |
| 14 | |
| 15 | if conf.options.debug: |
| 16 | conf.define ('_DEBUG', 1) |
| 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) |
| 32 | else: |
| 33 | flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations'] |
| 34 | conf.add_supported_cxxflags (cxxflags = flags) |
| 35 | |
| 36 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True) |
| 37 | |
| 38 | def build (bld): |
| 39 | bld ( |
| 40 | features=['cxx', 'cxxprogram'], |
| 41 | target="nlsr", |
| 42 | source = bld.path.ant_glob('*.cpp'), |
| 43 | use = 'NDN_CPP', |
| 44 | ) |
| 45 | |
| 46 | @Configure.conf |
| 47 | def add_supported_cxxflags(self, cxxflags): |
| 48 | """ |
| 49 | Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable |
| 50 | """ |
| 51 | self.start_msg('Checking allowed flags for c++ compiler') |
| 52 | |
| 53 | supportedFlags = [] |
| 54 | for flag in cxxflags: |
| 55 | if self.check_cxx (cxxflags=[flag], mandatory=False): |
| 56 | supportedFlags += [flag] |
| 57 | |
| 58 | self.end_msg (' '.join (supportedFlags)) |
| 59 | self.env.CXXFLAGS += supportedFlags |
| 60 | |