blob: cf5f8bf14173aae49f96b016fb0a6bed412ff1ed [file] [log] [blame]
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev71b43e72012-12-27 01:03:43 -08003VERSION='0.1'
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08004APPNAME='chronoshare'
Zhenkai Zhubad089c2012-12-28 10:28:27 -08005CCNXLIB='ccnx'
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08006
7from waflib import Build, Logs
8
9def 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 Afanasyev71b43e72012-12-27 01:03:43 -080012 opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080013
Alexander Afanasyev6f70a0f2013-01-02 20:44:09 -080014 opt.load('compiler_cxx boost ccnx protoc ice_cxx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080015
16def configure(conf):
17 conf.load("compiler_cxx")
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080018
Alexander Afanasyevf2890632013-01-02 13:40:02 -080019 conf.define ("CHRONOSHARE_VERSION", VERSION)
20
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080021 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
22
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080023 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080024 libcrypto = conf.check_cc(lib='crypto',
25 header_name='openssl/crypto.h',
26 define_name='HAVE_SSL',
27 uselib_store='SSL')
28 else:
29 conf.define ("HAVE_SSL", 1)
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080030 if not conf.get_define ("HAVE_SSL"):
31 conf.fatal ("Cannot find SSL libraries")
32
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080033 conf.load ('ccnx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080034 conf.load('boost')
35
Zhenkai Zhu9bdb6252012-12-28 14:32:47 -080036 conf.check_boost(lib='system iostreams regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080037
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080038 boost_version = conf.env.BOOST_VERSION.split('_')
39 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
40 Logs.error ("Minumum required boost version is 1.46")
41 return
42
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080043 conf.check_ccnx (path=conf.options.ccnx_dir)
44
45 if conf.options.debug:
46 conf.define ('_DEBUG', 1)
47 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
48 else:
49 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
50
51 if conf.options._test:
52 conf.define('_TEST', 1)
53
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080054 conf.load('protoc')
Alexander Afanasyev8811b352013-01-02 12:51:15 -080055 conf.load('ice_cxx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080056
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080057 conf.write_config_header('src/config.h')
58
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080059def build (bld):
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080060 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080061 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080062 features=['cxx', 'cxxshlib'],
63 source = [
64 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080065 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080066 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080067 'src/ccnx-tunnel.cpp',
Zhenkai Zhuf47109b2013-01-02 19:41:34 -080068 'src/object-db-file.cpp',
69 'src/ccnx-name.cpp',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080070 ],
71 use = 'BOOST BOOST_THREAD SSL CCNX',
72 includes = ['include', ],
73 )
Zhenkai Zhud4d4dfa2013-01-02 13:16:36 -080074
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080075 # Unit tests
76 if bld.get_define("_TEST"):
77 unittests = bld.program (
78 target="unit-tests",
79 source = bld.path.ant_glob(['test/**/*.cc']),
80 features=['cxx', 'cxxprogram'],
81 use = 'BOOST_TEST',
82 includes = ['include', ],
83 )
84
Alexander Afanasyevf2890632013-01-02 13:40:02 -080085 common = bld.objects (
86 target = "common",
87 features = ["cxx"],
Alexander Afanasyeva199f972013-01-02 19:37:26 -080088 source = ['src/hash-helper.cc',
89 'src/chronoshare-client.ice',
90 ],
Alexander Afanasyevf2890632013-01-02 13:40:02 -080091 use = 'BOOST',
92 includes = ['include', 'src'],
93 )
94
95
96 client = bld (
97 target="cs-client",
98 features=['cxx', 'cxxprogram'],
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080099 source = ['client/client.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800100 ],
101 use = "BOOST CCNX SSL ICE common",
102 includes = ['include', 'src'],
103 )
104
105 daemon = bld (
106 target="cs-daemon",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800107 features=['cxx', 'cxxprogram'],
108 # source = bld.path.ant_glob(['src/**/*.cc']),
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800109 source = ['daemon/daemon.cc',
110 'daemon/notify-i.cc',
Alexander Afanasyev242f8772013-01-01 23:26:31 -0800111 'src/db-helper.cc',
Alexander Afanasyeva199f972013-01-02 19:37:26 -0800112 'src/sync-log.cc',
113 'src/action-log.cc',
Alexander Afanasyev6f70a0f2013-01-02 20:44:09 -0800114 'src/sync-state.proto',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800115 ],
116 use = "BOOST CCNX SSL SQLITE3 ICE common",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800117 includes = ['include', 'src'],
118 )