blob: 92949b7a039b8a9f665ea100311e19db5d75b19e [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 Afanasyev33206982013-01-09 16:29:29 -080014 opt.load('compiler_cxx boost ccnx protoc ice_cxx qt4')
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)
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080022 conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True)
23 conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True)
24
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080025 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080026 libcrypto = conf.check_cc(lib='crypto',
27 header_name='openssl/crypto.h',
28 define_name='HAVE_SSL',
29 uselib_store='SSL')
30 else:
31 conf.define ("HAVE_SSL", 1)
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080032 if not conf.get_define ("HAVE_SSL"):
33 conf.fatal ("Cannot find SSL libraries")
34
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080035 conf.load ('ccnx')
Alexander Afanasyev33206982013-01-09 16:29:29 -080036
37 conf.load('protoc')
38 conf.load('ice_cxx')
39
40 conf.load('qt4')
41
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080042 conf.load('boost')
43
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080044 conf.check_boost(lib='system test iostreams filesystem regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080045
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080046 boost_version = conf.env.BOOST_VERSION.split('_')
47 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
48 Logs.error ("Minumum required boost version is 1.46")
49 return
50
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080051 conf.check_ccnx (path=conf.options.ccnx_dir)
52
53 if conf.options.debug:
54 conf.define ('_DEBUG', 1)
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080055 conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-fcolor-diagnostics', '-g3'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080056 else:
57 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
58
59 if conf.options._test:
Alexander Afanasyev72ac2192013-01-03 19:33:43 -080060 conf.env.TEST = 1
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080061
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080062 conf.write_config_header('src/config.h')
63
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080064def build (bld):
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080065 common = bld.objects (
66 target = "common",
67 features = ["cxx"],
68 source = ['src/hash-helper.cc',
69 'src/chronoshare-client.ice',
70 ],
71 use = 'BOOST',
72 includes = ['include', 'src'],
73 )
74
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080075 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080076 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080077 features=['cxx', 'cxxshlib'],
78 source = [
79 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080080 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080081 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080082 'src/ccnx-tunnel.cpp',
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080083 'src/object-db.cc',
84 'src/object-manager.cc',
Zhenkai Zhuf47109b2013-01-02 19:41:34 -080085 'src/ccnx-name.cpp',
Zhenkai Zhua6472e02013-01-06 14:33:37 -080086 'src/ccnx-selectors.cpp',
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080087 'src/event-scheduler.cpp',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080088 ],
Zhenkai Zhu608f7b32013-01-08 19:57:11 -080089 use = 'BOOST BOOST_THREAD BOOST_FILESYSTEM SSL SQLITE3 CCNX common LIBEVENT LIBEVENT_PTHREADS',
Alexander Afanasyevf2890632013-01-02 13:40:02 -080090 includes = ['include', 'src'],
91 )
92
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080093 database = bld.objects (
94 target = "database",
95 features = ["cxx"],
96 source = [
97 'src/db-helper.cc',
98 'src/sync-log.cc',
99 'src/action-log.cc',
100 'src/action-item.proto',
101 'src/sync-state.proto',
Zhenkai Zhue851b952013-01-13 22:29:57 -0800102 'src/sync-core.cc',
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800103 ],
104 use = "BOOST SQLITE3 SSL common",
105 includes = ['include', 'src'],
106 )
107
108 # Unit tests
109 if bld.env['TEST']:
110 unittests = bld.program (
111 target="unit-tests",
112 source = bld.path.ant_glob(['test/**/*.cc']),
113 features=['cxx', 'cxxprogram'],
Zhenkai Zhue29616f2013-01-14 15:40:57 -0800114 use = 'BOOST_TEST BOOST_FILESYSTEM ccnxx database',
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800115 includes = ['include', 'src'],
116 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800117
118 client = bld (
119 target="cs-client",
120 features=['cxx', 'cxxprogram'],
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800121 source = ['client/client.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800122 ],
123 use = "BOOST CCNX SSL ICE common",
124 includes = ['include', 'src'],
125 )
126
127 daemon = bld (
128 target="cs-daemon",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800129 features=['cxx', 'cxxprogram'],
130 # source = bld.path.ant_glob(['src/**/*.cc']),
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800131 source = ['daemon/daemon.cc',
132 'daemon/notify-i.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800133 ],
Alexander Afanasyevd09871f2013-01-04 22:36:37 -0800134 use = "BOOST CCNX SSL SQLITE3 ICE common database ccnxx",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800135 includes = ['include', 'src'],
136 )
Alexander Afanasyev33206982013-01-09 16:29:29 -0800137
Alexander Afanasyevff731962013-01-09 17:16:28 -0800138
139
Alexander Afanasyev33206982013-01-09 16:29:29 -0800140 qt = bld (
Jared Lindblom2eead682013-01-12 20:26:21 -0800141 target = "filewatcher",
Alexander Afanasyev33206982013-01-09 16:29:29 -0800142 features = "qt4 cxx cxxprogram",
Alexander Afanasyevff731962013-01-09 17:16:28 -0800143 defines = "WAF",
Jared Lindblom2eead682013-01-12 20:26:21 -0800144 source = "filesystemwatcher/filesystemwatcher.cpp filesystemwatcher/simpleeventcatcher.cpp filesystemwatcher/main.cpp",
Alexander Afanasyev33206982013-01-09 16:29:29 -0800145 includes = "filesystemwatcher src include .",
Jared Lindblom2eead682013-01-12 20:26:21 -0800146 use = "QTCORE QTGUI"
Alexander Afanasyev33206982013-01-09 16:29:29 -0800147 )