blob: b7991ae90a0ec1851e51c3c4231a2faaf4f88ea1 [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')
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 Afanasyev71b43e72012-12-27 01:03:43 -080019 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
20
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080021 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080022 libcrypto = conf.check_cc(lib='crypto',
23 header_name='openssl/crypto.h',
24 define_name='HAVE_SSL',
25 uselib_store='SSL')
26 else:
27 conf.define ("HAVE_SSL", 1)
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080028 if not conf.get_define ("HAVE_SSL"):
29 conf.fatal ("Cannot find SSL libraries")
30
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080031 conf.load ('ccnx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080032 conf.load('boost')
33
Zhenkai Zhu9bdb6252012-12-28 14:32:47 -080034 conf.check_boost(lib='system iostreams regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080035
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080036 boost_version = conf.env.BOOST_VERSION.split('_')
37 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
38 Logs.error ("Minumum required boost version is 1.46")
39 return
40
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080041 conf.check_ccnx (path=conf.options.ccnx_dir)
42
43 if conf.options.debug:
44 conf.define ('_DEBUG', 1)
45 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
46 else:
47 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
48
49 if conf.options._test:
50 conf.define('_TEST', 1)
51
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080052 conf.load('protoc')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080053
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080054 conf.write_config_header('src/config.h')
55
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080056def build (bld):
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080057 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080058 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080059 features=['cxx', 'cxxshlib'],
60 source = [
61 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080062 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080063 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080064 'src/ccnx-tunnel.cpp',
Zhenkai Zhud4d4dfa2013-01-02 13:16:36 -080065 'src/object-db-file.cpp'
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080066 ],
67 use = 'BOOST BOOST_THREAD SSL CCNX',
68 includes = ['include', ],
69 )
Zhenkai Zhud4d4dfa2013-01-02 13:16:36 -080070
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080071 # Unit tests
72 if bld.get_define("_TEST"):
73 unittests = bld.program (
74 target="unit-tests",
75 source = bld.path.ant_glob(['test/**/*.cc']),
76 features=['cxx', 'cxxprogram'],
77 use = 'BOOST_TEST',
78 includes = ['include', ],
79 )
80
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080081 chronoshare = bld (
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080082 target="tmp",
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080083 features=['cxx', 'cxxprogram'],
84 # source = bld.path.ant_glob(['src/**/*.cc']),
Zhenkai Zhud4d4dfa2013-01-02 13:16:36 -080085 source = ['src/main.cc',
Alexander Afanasyevde1cdd02012-12-29 14:41:46 -080086 'src/sqlite-helper.cc',
87 'src/hash-string-converter.cc'],
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080088 use = 'BOOST BOOST_IOSTREAMS BOOST_REGEX CCNX SSL SQLITE3',
89 includes = ['include', 'src'],
90 )