blob: c8f63ad1a044e80bad80e7eeaaa17448f1fffe1a [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 Afanasyev71b43e72012-12-27 01:03:43 -080020 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
21
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080022 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080023 libcrypto = conf.check_cc(lib='crypto',
24 header_name='openssl/crypto.h',
25 define_name='HAVE_SSL',
26 uselib_store='SSL')
27 else:
28 conf.define ("HAVE_SSL", 1)
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080029 if not conf.get_define ("HAVE_SSL"):
30 conf.fatal ("Cannot find SSL libraries")
31
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080032 conf.load ('ccnx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080033 conf.load('boost')
34
Zhenkai Zhu9bdb6252012-12-28 14:32:47 -080035 conf.check_boost(lib='system iostreams regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080036
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080037 boost_version = conf.env.BOOST_VERSION.split('_')
38 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
39 Logs.error ("Minumum required boost version is 1.46")
40 return
41
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080042 conf.check_ccnx (path=conf.options.ccnx_dir)
43
44 if conf.options.debug:
45 conf.define ('_DEBUG', 1)
46 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
47 else:
48 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
49
50 if conf.options._test:
51 conf.define('_TEST', 1)
52
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080053 conf.load('protoc')
Alexander Afanasyev8811b352013-01-02 12:51:15 -080054 conf.load('ice_cxx')
55
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080056 conf.write_config_header('src/config.h')
57
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080058def build (bld):
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080059 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080060 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080061 features=['cxx', 'cxxshlib'],
62 source = [
63 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080064 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080065 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080066 'src/ccnx-tunnel.cpp',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080067 ],
68 use = 'BOOST BOOST_THREAD SSL CCNX',
69 includes = ['include', ],
70 )
71
72 # Unit tests
73 if bld.get_define("_TEST"):
74 unittests = bld.program (
75 target="unit-tests",
76 source = bld.path.ant_glob(['test/**/*.cc']),
77 features=['cxx', 'cxxprogram'],
78 use = 'BOOST_TEST',
79 includes = ['include', ],
80 )
81
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080082 chronoshare = bld (
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080083 target="tmp",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080084 features=['cxx', 'cxxprogram'],
85 # source = bld.path.ant_glob(['src/**/*.cc']),
Alexander Afanasyevde1cdd02012-12-29 14:41:46 -080086 source = ['src/main.cc',
Alexander Afanasyev242f8772013-01-01 23:26:31 -080087 'src/db-helper.cc',
Alexander Afanasyev8811b352013-01-02 12:51:15 -080088 'src/hash-string-converter.cc',
89 'src/chronoshare-client.ice'],
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080090 use = 'BOOST BOOST_IOSTREAMS BOOST_REGEX CCNX SSL SQLITE3',
91 includes = ['include', 'src'],
92 )