blob: 43d8d8f46c725db18d31d35d2033cee07e423538 [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'
Alexander Afanasyevd09871f2013-01-04 22:36:37 -08005CCNXLIB='ccnxx'
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
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080036 conf.check_boost(lib='system test iostreams filesystem 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)
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080047 conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-fcolor-diagnostics', '-g3'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080048 else:
49 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
50
51 if conf.options._test:
Alexander Afanasyev72ac2192013-01-03 19:33:43 -080052 conf.env.TEST = 1
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080053
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):
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080060 common = bld.objects (
61 target = "common",
62 features = ["cxx"],
63 source = ['src/hash-helper.cc',
64 'src/chronoshare-client.ice',
65 ],
66 use = 'BOOST',
67 includes = ['include', 'src'],
68 )
69
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080070 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080071 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080072 features=['cxx', 'cxxshlib'],
73 source = [
74 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080075 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080076 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080077 'src/ccnx-tunnel.cpp',
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080078 'src/object-db.cc',
79 'src/object-manager.cc',
Zhenkai Zhuf47109b2013-01-02 19:41:34 -080080 'src/ccnx-name.cpp',
Zhenkai Zhua6472e02013-01-06 14:33:37 -080081 'src/ccnx-selectors.cpp',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080082 ],
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080083 use = 'BOOST BOOST_THREAD BOOST_FILESYSTEM SSL SQLITE3 CCNX common',
Alexander Afanasyevf2890632013-01-02 13:40:02 -080084 includes = ['include', 'src'],
85 )
86
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080087 database = bld.objects (
88 target = "database",
89 features = ["cxx"],
90 source = [
91 'src/db-helper.cc',
92 'src/sync-log.cc',
93 'src/action-log.cc',
94 'src/action-item.proto',
95 'src/sync-state.proto',
96 ],
97 use = "BOOST SQLITE3 SSL common",
98 includes = ['include', 'src'],
99 )
100
101 # Unit tests
102 if bld.env['TEST']:
103 unittests = bld.program (
104 target="unit-tests",
105 source = bld.path.ant_glob(['test/**/*.cc']),
106 features=['cxx', 'cxxprogram'],
Alexander Afanasyevd09871f2013-01-04 22:36:37 -0800107 use = 'BOOST_TEST ccnxx database',
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800108 includes = ['include', 'src'],
109 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800110
111 client = bld (
112 target="cs-client",
113 features=['cxx', 'cxxprogram'],
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800114 source = ['client/client.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800115 ],
116 use = "BOOST CCNX SSL ICE common",
117 includes = ['include', 'src'],
118 )
119
120 daemon = bld (
121 target="cs-daemon",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800122 features=['cxx', 'cxxprogram'],
123 # source = bld.path.ant_glob(['src/**/*.cc']),
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800124 source = ['daemon/daemon.cc',
125 'daemon/notify-i.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800126 ],
Alexander Afanasyevd09871f2013-01-04 22:36:37 -0800127 use = "BOOST CCNX SSL SQLITE3 ICE common database ccnxx",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800128 includes = ['include', 'src'],
129 )