blob: af3befdb5ef7ec5459dacbec6925dac157767715 [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
14 opt.load('compiler_cxx boost ccnx protoc')
Alexander Afanasyev8811b352013-01-02 12:51:15 -080015 opt.load('ice_cxx', tooldir=["."])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080016
17def configure(conf):
18 conf.load("compiler_cxx")
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080019
Alexander Afanasyevf2890632013-01-02 13:40:02 -080020 conf.define ("CHRONOSHARE_VERSION", VERSION)
21
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080022 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
23
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080024 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080025 libcrypto = conf.check_cc(lib='crypto',
26 header_name='openssl/crypto.h',
27 define_name='HAVE_SSL',
28 uselib_store='SSL')
29 else:
30 conf.define ("HAVE_SSL", 1)
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080031 if not conf.get_define ("HAVE_SSL"):
32 conf.fatal ("Cannot find SSL libraries")
33
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080034 conf.load ('ccnx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080035 conf.load('boost')
36
Zhenkai Zhu9bdb6252012-12-28 14:32:47 -080037 conf.check_boost(lib='system iostreams regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080038
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080039 boost_version = conf.env.BOOST_VERSION.split('_')
40 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
41 Logs.error ("Minumum required boost version is 1.46")
42 return
43
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080044 conf.check_ccnx (path=conf.options.ccnx_dir)
45
46 if conf.options.debug:
47 conf.define ('_DEBUG', 1)
48 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
49 else:
50 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
51
52 if conf.options._test:
53 conf.define('_TEST', 1)
54
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080055 conf.load('protoc')
Alexander Afanasyev8811b352013-01-02 12:51:15 -080056 conf.load('ice_cxx')
57
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080058 conf.write_config_header('src/config.h')
59
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080060def build (bld):
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080061 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080062 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080063 features=['cxx', 'cxxshlib'],
64 source = [
65 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080066 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080067 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080068 'src/ccnx-tunnel.cpp',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080069 ],
70 use = 'BOOST BOOST_THREAD SSL CCNX',
71 includes = ['include', ],
72 )
73
74 # Unit tests
75 if bld.get_define("_TEST"):
76 unittests = bld.program (
77 target="unit-tests",
78 source = bld.path.ant_glob(['test/**/*.cc']),
79 features=['cxx', 'cxxprogram'],
80 use = 'BOOST_TEST',
81 includes = ['include', ],
82 )
83
Alexander Afanasyevf2890632013-01-02 13:40:02 -080084 common = bld.objects (
85 target = "common",
86 features = ["cxx"],
87 source = bld.path.ant_glob(
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080088 'src/chronoshare-client.ice'
Alexander Afanasyevf2890632013-01-02 13:40:02 -080089 ),
90 use = 'BOOST',
91 includes = ['include', 'src'],
92 )
93
94
95 client = bld (
96 target="cs-client",
97 features=['cxx', 'cxxprogram'],
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -080098 source = ['client/client.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -080099 ],
100 use = "BOOST CCNX SSL ICE common",
101 includes = ['include', 'src'],
102 )
103
104 daemon = bld (
105 target="cs-daemon",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800106 features=['cxx', 'cxxprogram'],
107 # source = bld.path.ant_glob(['src/**/*.cc']),
Alexander Afanasyev5e9e46e2013-01-02 14:12:50 -0800108 source = ['daemon/daemon.cc',
109 'daemon/notify-i.cc',
Alexander Afanasyev242f8772013-01-01 23:26:31 -0800110 'src/db-helper.cc',
Alexander Afanasyev8811b352013-01-02 12:51:15 -0800111 'src/hash-string-converter.cc',
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800112 ],
113 use = "BOOST CCNX SSL SQLITE3 ICE common",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800114 includes = ['include', 'src'],
115 )