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 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 3 | VERSION='0.1' |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 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''') |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 12 | opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 13 | |
| 14 | opt.load('compiler_cxx boost ccnx protoc') |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame] | 15 | opt.load('ice_cxx', tooldir=["."]) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 16 | |
| 17 | def configure(conf): |
| 18 | conf.load("compiler_cxx") |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 20 | conf.define ("CHRONOSHARE_VERSION", VERSION) |
| 21 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 22 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
| 23 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 24 | if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False): |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 25 | libcrypto = conf.check_cc(lib='crypto', |
| 26 | header_name='openssl/crypto.h', |
| 27 | define_name='HAVE_SSL', |
| 28 | uselib_store='SSL') |
| 29 | else: |
| 30 | conf.define ("HAVE_SSL", 1) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 31 | if not conf.get_define ("HAVE_SSL"): |
| 32 | conf.fatal ("Cannot find SSL libraries") |
| 33 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 34 | conf.load ('ccnx') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 35 | conf.load('boost') |
| 36 | |
Zhenkai Zhu | 9bdb625 | 2012-12-28 14:32:47 -0800 | [diff] [blame] | 37 | conf.check_boost(lib='system iostreams regex thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 38 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 39 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 40 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 41 | Logs.error ("Minumum required boost version is 1.46") |
| 42 | return |
| 43 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 44 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 45 | |
| 46 | if conf.options.debug: |
| 47 | conf.define ('_DEBUG', 1) |
| 48 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
| 49 | else: |
| 50 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 51 | |
| 52 | if conf.options._test: |
| 53 | conf.define('_TEST', 1) |
| 54 | |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 55 | conf.load('protoc') |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame] | 56 | conf.load('ice_cxx') |
| 57 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 58 | conf.write_config_header('src/config.h') |
| 59 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 60 | def build (bld): |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 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 | 974c5a6 | 2012-12-28 14:15:30 -0800 | [diff] [blame] | 67 | 'src/ccnx-closure.cpp', |
Zhenkai Zhu | d492431 | 2012-12-28 11:35:12 -0800 | [diff] [blame] | 68 | 'src/ccnx-tunnel.cpp', |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 69 | ], |
| 70 | use = 'BOOST BOOST_THREAD SSL CCNX', |
| 71 | includes = ['include', ], |
| 72 | ) |
| 73 | |
| 74 | # Unit tests |
| 75 | if bld.get_define("_TEST"): |
| 76 | unittests = bld.program ( |
| 77 | target="unit-tests", |
| 78 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 79 | features=['cxx', 'cxxprogram'], |
| 80 | use = 'BOOST_TEST', |
| 81 | includes = ['include', ], |
| 82 | ) |
| 83 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 84 | common = bld.objects ( |
| 85 | target = "common", |
| 86 | features = ["cxx"], |
| 87 | source = bld.path.ant_glob( |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame^] | 88 | 'src/chronoshare-client.ice' |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 89 | ), |
| 90 | use = 'BOOST', |
| 91 | includes = ['include', 'src'], |
| 92 | ) |
| 93 | |
| 94 | |
| 95 | client = bld ( |
| 96 | target="cs-client", |
| 97 | features=['cxx', 'cxxprogram'], |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame^] | 98 | source = ['client/client.cc', |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 99 | ], |
| 100 | use = "BOOST CCNX SSL ICE common", |
| 101 | includes = ['include', 'src'], |
| 102 | ) |
| 103 | |
| 104 | daemon = bld ( |
| 105 | target="cs-daemon", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 106 | features=['cxx', 'cxxprogram'], |
| 107 | # source = bld.path.ant_glob(['src/**/*.cc']), |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame^] | 108 | source = ['daemon/daemon.cc', |
| 109 | 'daemon/notify-i.cc', |
Alexander Afanasyev | 242f877 | 2013-01-01 23:26:31 -0800 | [diff] [blame] | 110 | 'src/db-helper.cc', |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame] | 111 | 'src/hash-string-converter.cc', |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 112 | ], |
| 113 | use = "BOOST CCNX SSL SQLITE3 ICE common", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 114 | includes = ['include', 'src'], |
| 115 | ) |