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') |
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 | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 19 | conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True) |
| 20 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 21 | 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] | 22 | libcrypto = conf.check_cc(lib='crypto', |
| 23 | header_name='openssl/crypto.h', |
| 24 | define_name='HAVE_SSL', |
| 25 | uselib_store='SSL') |
| 26 | else: |
| 27 | conf.define ("HAVE_SSL", 1) |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 28 | if not conf.get_define ("HAVE_SSL"): |
| 29 | conf.fatal ("Cannot find SSL libraries") |
| 30 | |
Zhenkai Zhu | 0a17aea | 2012-12-28 14:30:22 -0800 | [diff] [blame] | 31 | conf.load ('ccnx') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 32 | conf.load('boost') |
| 33 | |
Zhenkai Zhu | 9bdb625 | 2012-12-28 14:32:47 -0800 | [diff] [blame] | 34 | conf.check_boost(lib='system iostreams regex thread') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 35 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 36 | boost_version = conf.env.BOOST_VERSION.split('_') |
| 37 | if int(boost_version[0]) < 1 or int(boost_version[1]) < 46: |
| 38 | Logs.error ("Minumum required boost version is 1.46") |
| 39 | return |
| 40 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 41 | conf.check_ccnx (path=conf.options.ccnx_dir) |
| 42 | |
| 43 | if conf.options.debug: |
| 44 | conf.define ('_DEBUG', 1) |
| 45 | conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) |
| 46 | else: |
| 47 | conf.env.append_value('CXXFLAGS', ['-O3', '-g']) |
| 48 | |
| 49 | if conf.options._test: |
| 50 | conf.define('_TEST', 1) |
| 51 | |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 52 | conf.load('protoc') |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 53 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 54 | conf.write_config_header('src/config.h') |
| 55 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 56 | def build (bld): |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 57 | libccnx = bld ( |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 58 | target=CCNXLIB, |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 59 | features=['cxx', 'cxxshlib'], |
| 60 | source = [ |
| 61 | 'src/ccnx-wrapper.cpp', |
Zhenkai Zhu | bad089c | 2012-12-28 10:28:27 -0800 | [diff] [blame] | 62 | 'src/ccnx-pco.cpp', |
Zhenkai Zhu | 974c5a6 | 2012-12-28 14:15:30 -0800 | [diff] [blame] | 63 | 'src/ccnx-closure.cpp', |
Zhenkai Zhu | d492431 | 2012-12-28 11:35:12 -0800 | [diff] [blame] | 64 | 'src/ccnx-tunnel.cpp', |
Zhenkai Zhu | d4d4dfa | 2013-01-02 13:16:36 -0800 | [diff] [blame^] | 65 | 'src/object-db-file.cpp' |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 66 | ], |
| 67 | use = 'BOOST BOOST_THREAD SSL CCNX', |
| 68 | includes = ['include', ], |
| 69 | ) |
Zhenkai Zhu | d4d4dfa | 2013-01-02 13:16:36 -0800 | [diff] [blame^] | 70 | |
Zhenkai Zhu | a7e3da7 | 2012-12-27 13:45:00 -0800 | [diff] [blame] | 71 | # Unit tests |
| 72 | if bld.get_define("_TEST"): |
| 73 | unittests = bld.program ( |
| 74 | target="unit-tests", |
| 75 | source = bld.path.ant_glob(['test/**/*.cc']), |
| 76 | features=['cxx', 'cxxprogram'], |
| 77 | use = 'BOOST_TEST', |
| 78 | includes = ['include', ], |
| 79 | ) |
| 80 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 81 | chronoshare = bld ( |
Alexander Afanasyev | 5f9d09e | 2012-12-28 19:43:08 -0800 | [diff] [blame] | 82 | target="tmp", |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 83 | features=['cxx', 'cxxprogram'], |
| 84 | # source = bld.path.ant_glob(['src/**/*.cc']), |
Zhenkai Zhu | d4d4dfa | 2013-01-02 13:16:36 -0800 | [diff] [blame^] | 85 | source = ['src/main.cc', |
Alexander Afanasyev | de1cdd0 | 2012-12-29 14:41:46 -0800 | [diff] [blame] | 86 | 'src/sqlite-helper.cc', |
| 87 | 'src/hash-string-converter.cc'], |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 88 | use = 'BOOST BOOST_IOSTREAMS BOOST_REGEX CCNX SSL SQLITE3', |
| 89 | includes = ['include', 'src'], |
| 90 | ) |