blob: 6ec706ff4146877e1f792e4ce8de5a26f014a6bd [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 Zhubc2f6282013-01-08 16:40:58 -080023 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 Zhua7e3da72012-12-27 13:45:00 -080026 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080027 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 Zhua7e3da72012-12-27 13:45:00 -080033 if not conf.get_define ("HAVE_SSL"):
34 conf.fatal ("Cannot find SSL libraries")
35
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080036 conf.load ('ccnx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080037 conf.load('boost')
38
Zhenkai Zhua28734b2013-01-03 19:23:40 -080039 conf.check_boost(lib='system test iostreams regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080040
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080041 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 Zhua7e3da72012-12-27 13:45:00 -080046 conf.check_ccnx (path=conf.options.ccnx_dir)
47
48 if conf.options.debug:
49 conf.define ('_DEBUG', 1)
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080050 conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-fcolor-diagnostics', '-g3'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080051 else:
52 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
53
54 if conf.options._test:
Alexander Afanasyev72ac2192013-01-03 19:33:43 -080055 conf.env.TEST = 1
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080056
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080057 conf.load('protoc')
Alexander Afanasyev8811b352013-01-02 12:51:15 -080058 conf.load('ice_cxx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080059
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080060 conf.write_config_header('src/config.h')
61
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080062def build (bld):
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080063 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080064 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080065 features=['cxx', 'cxxshlib'],
66 source = [
67 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080068 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080069 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080070 'src/ccnx-tunnel.cpp',
Zhenkai Zhuf47109b2013-01-02 19:41:34 -080071 'src/object-db-file.cpp',
72 'src/ccnx-name.cpp',
Zhenkai Zhua6472e02013-01-06 14:33:37 -080073 'src/ccnx-selectors.cpp',
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080074 'src/event-scheduler.cpp',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080075 ],
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080076 use = 'BOOST BOOST_THREAD SSL CCNX LIBEVENT LIBEVENT_PTHREADS',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080077 includes = ['include', ],
78 )
Zhenkai Zhud4d4dfa2013-01-02 13:16:36 -080079
Alexander Afanasyevf2890632013-01-02 13:40:02 -080080 common = bld.objects (
81 target = "common",
82 features = ["cxx"],
Alexander Afanasyeva199f972013-01-02 19:37:26 -080083 source = ['src/hash-helper.cc',
84 'src/chronoshare-client.ice',
85 ],
Alexander Afanasyevf2890632013-01-02 13:40:02 -080086 use = 'BOOST',
87 includes = ['include', 'src'],
88 )
89
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080090 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 Zhubc2f6282013-01-08 16:40:58 -0800110 use = 'BOOST_TEST LIBEVENT LIBEVENT_PTHREADS ccnxx database',
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800111 includes = ['include', 'src'],
112 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800113
114 client = bld (
115 target="cs-client",
116 features=['cxx', 'cxxprogram'],
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800117 source = ['client/client.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800118 ],
119 use = "BOOST CCNX SSL ICE common",
120 includes = ['include', 'src'],
121 )
122
123 daemon = bld (
124 target="cs-daemon",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800125 features=['cxx', 'cxxprogram'],
126 # source = bld.path.ant_glob(['src/**/*.cc']),
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800127 source = ['daemon/daemon.cc',
128 'daemon/notify-i.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800129 ],
Alexander Afanasyevd09871f2013-01-04 22:36:37 -0800130 use = "BOOST CCNX SSL SQLITE3 ICE common database ccnxx",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800131 includes = ['include', 'src'],
132 )