Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 3 | VERSION='0.0.1' |
| 4 | APPNAME='sync' |
| 5 | |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 6 | def options(opt): |
Alexander Afanasyev | 87c9b5d | 2012-03-07 17:23:21 -0800 | [diff] [blame] | 7 | opt.add_option('--no-debug',action='store_true',default=False,dest='no_debug',help='''Make an optimized build of the library (remove debugging code)''') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame^] | 8 | opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx/native NS3 logging support''') |
| 9 | opt.add_option('--ns3', action='store_true',default=False,dest='ns3_enable',help='''Compile as NS-3 module''') |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 10 | opt.load('compiler_c') |
| 11 | opt.load('compiler_cxx') |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 12 | opt.load('boost') |
| 13 | opt.load('doxygen') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame^] | 14 | opt.load('ccnx tinyxml ns3', tooldir=["waf-tools"]) |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 15 | |
Alexander Afanasyev | 8f25cbb | 2012-03-01 23:53:40 -0800 | [diff] [blame] | 16 | def configure(conf): |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 17 | conf.load("compiler_cxx") |
Chaoyi Bian | 9813519 | 2012-03-27 18:34:11 -0700 | [diff] [blame] | 18 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 19 | |
| 20 | if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False): |
| 21 | libcrypto = conf.check_cc(lib='crypto', |
| 22 | header_name='openssl/crypto.h', |
| 23 | define_name='HAVE_SSL', |
| 24 | uselib_store='SSL') |
| 25 | if not conf.get_define ("HAVE_SSL"): |
| 26 | conf.fatal ("Cannot find SSL libraries") |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 27 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 28 | conf.load('boost') |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame^] | 29 | |
| 30 | if conf.options.ns3_enable: |
| 31 | conf.load('ns3') |
| 32 | conf.define('NS3_MODULE', 1) |
| 33 | conf.check_modules(['core', 'network', 'internet'], mandatory = True) |
| 34 | conf.check_modules(['NDNabstraction'], mandatory = True) |
| 35 | conf.check_modules(['point-to-point'], mandatory = False) |
| 36 | conf.check_modules(['point-to-point-layout'], mandatory = False) |
| 37 | |
| 38 | conf.check_boost(lib='system iostreams thread') |
| 39 | else: |
| 40 | conf.check_boost(lib='system iostreams test thread') |
| 41 | conf.define ('STANDALONE', 1) |
| 42 | |
| 43 | if not conf.options.no_debug: |
| 44 | conf.define ('_DEBUG', 1) |
| 45 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 46 | |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 47 | try: |
| 48 | conf.load('doxygen') |
| 49 | except: |
| 50 | pass |
| 51 | |
Alexander Afanasyev | 250a4c4 | 2012-03-07 13:40:18 -0800 | [diff] [blame] | 52 | conf.load('ccnx tinyxml') |
| 53 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 54 | conf.check_tinyxml (path=conf.options.ccnx_dir) |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 55 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame^] | 56 | # else: |
| 57 | # if 'CXXFLAGS' in conf.env: |
| 58 | # tmp = conf.env['CXXFLAGS'] |
| 59 | # else: |
| 60 | # tmp = [] |
| 61 | # conf.env['CXXFLAGS'] = tmp + ['-g'] |
| 62 | # if 'CFLAGS' in conf.env: |
| 63 | # tmp = conf.env['CFLAGS'] |
| 64 | # else: |
| 65 | # tmp = [] |
| 66 | # conf.env['CFLAGS'] = tmp + ['-g'] |
| 67 | # _report_optional_feature(conf, "debug", "Debug Symbols", True, '') |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 68 | |
| 69 | if conf.options.log4cxx: |
| 70 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True) |
| 71 | |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 72 | def build (bld): |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame^] | 73 | if bld.get_define ("NS3_MODULE"): |
| 74 | sync_ns3 = bld.shlib ( |
| 75 | target = "sync-ns3", |
| 76 | features=['cxx', 'cxxshlib'], |
| 77 | use = 'BOOST BOOST_IOSTREAMS SSL TINYXML CCNX ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (), |
| 78 | source = bld.path.ant_glob(['model/sync-*.cc', |
| 79 | 'helper/sync-*.cc']), |
| 80 | ) |
| 81 | |
| 82 | |
| 83 | # from waflib import Utils,Logs,Errors |
| 84 | # Logs.pprint ('CYAN', program.use) |
| 85 | |
| 86 | else: |
| 87 | libsync = bld.shlib (target=APPNAME, |
| 88 | features=['cxx', 'cxxshlib'], |
| 89 | source = bld.path.ant_glob(['model/sync-*.cc', |
| 90 | 'helper/sync-*.cc']), |
| 91 | use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX') |
Alexander Afanasyev | ec1d4a7 | 2012-03-05 11:06:54 -0800 | [diff] [blame] | 92 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame^] | 93 | # Unit tests |
| 94 | unittests = bld.program (target="unit-tests", |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 95 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 96 | features=['cxx', 'cxxprogram'], |
| 97 | use = 'BOOST_TEST sync') |
| 98 | |
Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame^] | 99 | if bld.get_define ("HAVE_LOG4CXX"): |
| 100 | libsync.use += ' LOG4CXX' |
| 101 | unittests.use += ' LOG4CXX' |
Alexander Afanasyev | e76f263 | 2012-03-05 00:18:42 -0800 | [diff] [blame] | 102 | |
Alexander Afanasyev | 150f14d | 2012-03-05 21:24:49 -0800 | [diff] [blame] | 103 | # doxygen docs |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 104 | from waflib.Build import BuildContext |
| 105 | class doxy (BuildContext): |
| 106 | cmd = "doxygen" |
| 107 | fun = "doxygen" |
Alexander Afanasyev | 7a696fb | 2012-03-01 17:17:22 -0800 | [diff] [blame] | 108 | |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 109 | def doxygen (bld): |
Alexander Afanasyev | 34ebcb7 | 2012-03-08 15:54:55 -0800 | [diff] [blame] | 110 | if not bld.env.DOXYGEN: |
| 111 | bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
Alexander Afanasyev | 182fdc2 | 2012-03-05 18:06:52 -0800 | [diff] [blame] | 112 | bld (features="doxygen", |
| 113 | doxyfile='doc/doxygen.conf', |
| 114 | output_dir = 'doc') |