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' |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 5 | CCNXLIB='ccnxx' |
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 | |
Alexander Afanasyev | 6f70a0f | 2013-01-02 20:44:09 -0800 | [diff] [blame] | 14 | opt.load('compiler_cxx boost ccnx protoc ice_cxx') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 15 | |
| 16 | def configure(conf): |
| 17 | conf.load("compiler_cxx") |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 18 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 19 | conf.define ("CHRONOSHARE_VERSION", VERSION) |
| 20 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 21 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
| 22 | |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame^] | 23 | conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True) |
| 24 | conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True) |
| 25 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 26 | 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] | 27 | libcrypto = conf.check_cc(lib='crypto', |
| 28 | header_name='openssl/crypto.h', |
| 29 | define_name='HAVE_SSL', |
| 30 | uselib_store='SSL') |
| 31 | else: |
| 32 | conf.define ("HAVE_SSL", 1) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 33 | if not conf.get_define ("HAVE_SSL"): |
| 34 | conf.fatal ("Cannot find SSL libraries") |
| 35 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 36 | conf.load ('ccnx') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 37 | conf.load('boost') |
| 38 | |
Zhenkai Zhu | a28734b | 2013-01-03 19:23:40 -0800 | [diff] [blame] | 39 | conf.check_boost(lib='system test iostreams regex thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 40 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 41 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 42 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 43 | Logs.error ("Minumum required boost version is 1.46") |
| 44 | return |
| 45 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 46 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 47 | |
| 48 | if conf.options.debug: |
| 49 | conf.define ('_DEBUG', 1) |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 50 | conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-fcolor-diagnostics', '-g3']) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 51 | else: |
| 52 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 53 | |
| 54 | if conf.options._test: |
Alexander Afanasyev | 72ac219 | 2013-01-03 19:33:43 -0800 | [diff] [blame] | 55 | conf.env.TEST = 1 |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 56 | |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 57 | conf.load('protoc') |
Alexander Afanasyev | 8811b35 | 2013-01-02 12:51:15 -0800 | [diff] [blame] | 58 | conf.load('ice_cxx') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 59 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 60 | conf.write_config_header('src/config.h') |
| 61 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 62 | def build (bld): |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 63 | libccnx = bld ( |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 64 | target=CCNXLIB, |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 65 | features=['cxx', 'cxxshlib'], |
| 66 | source = [ |
| 67 | 'src/ccnx-wrapper.cpp', |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 68 | 'src/ccnx-pco.cpp', |
Zhenkai Zhu | 974c5a6 | 2012-12-28 14:15:30 -0800 | [diff] [blame] | 69 | 'src/ccnx-closure.cpp', |
Zhenkai Zhu | d492431 | 2012-12-28 11:35:12 -0800 | [diff] [blame] | 70 | 'src/ccnx-tunnel.cpp', |
Zhenkai Zhu | f47109b | 2013-01-02 19:41:34 -0800 | [diff] [blame] | 71 | 'src/object-db-file.cpp', |
| 72 | 'src/ccnx-name.cpp', |
Zhenkai Zhu | a6472e0 | 2013-01-06 14:33:37 -0800 | [diff] [blame] | 73 | 'src/ccnx-selectors.cpp', |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame^] | 74 | 'src/event-scheduler.cpp', |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 75 | ], |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame^] | 76 | use = 'BOOST BOOST_THREAD SSL CCNX LIBEVENT LIBEVENT_PTHREADS', |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 77 | includes = ['include', ], |
| 78 | ) |
Zhenkai Zhu | d4d4dfa | 2013-01-02 13:16:36 -0800 | [diff] [blame] | 79 | |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 80 | common = bld.objects ( |
| 81 | target = "common", |
| 82 | features = ["cxx"], |
Alexander Afanasyev | a199f97 | 2013-01-02 19:37:26 -0800 | [diff] [blame] | 83 | source = ['src/hash-helper.cc', |
| 84 | 'src/chronoshare-client.ice', |
| 85 | ], |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 86 | use = 'BOOST', |
| 87 | includes = ['include', 'src'], |
| 88 | ) |
| 89 | |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 90 | database = bld.objects ( |
| 91 | target = "database", |
| 92 | features = ["cxx"], |
| 93 | source = [ |
| 94 | 'src/db-helper.cc', |
| 95 | 'src/sync-log.cc', |
| 96 | 'src/action-log.cc', |
| 97 | 'src/action-item.proto', |
| 98 | 'src/sync-state.proto', |
| 99 | ], |
| 100 | use = "BOOST SQLITE3 SSL common", |
| 101 | includes = ['include', 'src'], |
| 102 | ) |
| 103 | |
| 104 | # Unit tests |
| 105 | if bld.env['TEST']: |
| 106 | unittests = bld.program ( |
| 107 | target="unit-tests", |
| 108 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 109 | features=['cxx', 'cxxprogram'], |
Zhenkai Zhu | bc2f628 | 2013-01-08 16:40:58 -0800 | [diff] [blame^] | 110 | use = 'BOOST_TEST LIBEVENT LIBEVENT_PTHREADS ccnxx database', |
Alexander Afanasyev | ee7e613 | 2013-01-03 20:03:14 -0800 | [diff] [blame] | 111 | includes = ['include', 'src'], |
| 112 | ) |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 113 | |
| 114 | client = bld ( |
| 115 | target="cs-client", |
| 116 | features=['cxx', 'cxxprogram'], |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 117 | source = ['client/client.cc', |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 118 | ], |
| 119 | use = "BOOST CCNX SSL ICE common", |
| 120 | includes = ['include', 'src'], |
| 121 | ) |
| 122 | |
| 123 | daemon = bld ( |
| 124 | target="cs-daemon", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 125 | features=['cxx', 'cxxprogram'], |
| 126 | # source = bld.path.ant_glob(['src/**/*.cc']), |
Alexander Afanasyev | 5e9e46e | 2013-01-02 14:12:50 -0800 | [diff] [blame] | 127 | source = ['daemon/daemon.cc', |
| 128 | 'daemon/notify-i.cc', |
Alexander Afanasyev | f289063 | 2013-01-02 13:40:02 -0800 | [diff] [blame] | 129 | ], |
Alexander Afanasyev | d09871f | 2013-01-04 22:36:37 -0800 | [diff] [blame] | 130 | use = "BOOST CCNX SSL SQLITE3 ICE common database ccnxx", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 131 | includes = ['include', 'src'], |
| 132 | ) |