Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | VERSION='0.0.1' |
| 4 | APPNAME='chronoshare' |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 5 | CCNXLIB='ccnx' |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 6 | |
| 7 | from waflib import Build, Logs |
| 8 | |
| 9 | def options(opt): |
| 10 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |
| 11 | opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''') |
| 12 | opt.load('compiler_c') |
| 13 | opt.load('compiler_cxx') |
| 14 | opt.load('boost') |
| 15 | opt.load('gnu_dirs') |
| 16 | opt.load('ccnx protobuf', tooldir=["waf-tools"]) |
| 17 | |
| 18 | def configure(conf): |
| 19 | conf.load("compiler_cxx") |
| 20 | conf.load('gnu_dirs') |
| 21 | |
| 22 | if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False): |
| 23 | libcrypto = conf.check_cc(lib='crypto', |
| 24 | header_name='openssl/crypto.h', |
| 25 | define_name='HAVE_SSL', |
| 26 | uselib_store='SSL') |
| 27 | if not conf.get_define ("HAVE_SSL"): |
| 28 | conf.fatal ("Cannot find SSL libraries") |
| 29 | |
| 30 | conf.load('boost') |
| 31 | |
Zhenkai Zhu | f3b852f | 2012-12-27 14:02:00 -0800 | [diff] [blame] | 32 | conf.check_boost(lib='system test thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 33 | |
| 34 | conf.load ('ccnx') |
| 35 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 36 | |
| 37 | if conf.options.debug: |
| 38 | conf.define ('_DEBUG', 1) |
| 39 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
| 40 | else: |
| 41 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 42 | |
| 43 | if conf.options._test: |
| 44 | conf.define('_TEST', 1) |
| 45 | |
| 46 | conf.load('protobuf') |
| 47 | |
| 48 | def build (bld): |
| 49 | bld.post_mode = Build.POST_LAZY |
| 50 | |
| 51 | bld.add_group ("protobuf") |
| 52 | |
| 53 | # x = bld ( |
| 54 | # features = ["protobuf"], |
| 55 | # source = ["model/sync-state.proto"], |
| 56 | # target = ["model/sync-state.pb"], |
| 57 | # ) |
| 58 | |
| 59 | bld.add_group ("code") |
| 60 | |
| 61 | libccnx = bld ( |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 62 | target=CCNXLIB, |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 63 | features=['cxx', 'cxxshlib'], |
| 64 | source = [ |
| 65 | 'src/ccnx-wrapper.cpp', |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 66 | 'src/ccnx-pco.cpp', |
Zhenkai Zhu | d492431 | 2012-12-28 11:35:12 -0800 | [diff] [blame^] | 67 | 'src/ccnx-tunnel.cpp', |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 68 | ], |
| 69 | use = 'BOOST BOOST_THREAD SSL CCNX', |
| 70 | includes = ['include', ], |
| 71 | ) |
| 72 | |
| 73 | # Unit tests |
| 74 | if bld.get_define("_TEST"): |
| 75 | unittests = bld.program ( |
| 76 | target="unit-tests", |
| 77 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 78 | features=['cxx', 'cxxprogram'], |
| 79 | use = 'BOOST_TEST', |
| 80 | includes = ['include', ], |
| 81 | ) |
| 82 | |
| 83 | |
| 84 | |
| 85 | |