blob: fecf6f4961d66a586b4fe74e5b451b7146145d21 [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
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080013 opt.load('compiler_c')
14 opt.load('compiler_cxx')
15 opt.load('boost')
16 opt.load('gnu_dirs')
17 opt.load('ccnx protobuf', tooldir=["waf-tools"])
18
19def configure(conf):
20 conf.load("compiler_cxx")
21 conf.load('gnu_dirs')
22
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080023 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', 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):
26 libcrypto = conf.check_cc(lib='crypto',
27 header_name='openssl/crypto.h',
28 define_name='HAVE_SSL',
29 uselib_store='SSL')
30 if not conf.get_define ("HAVE_SSL"):
31 conf.fatal ("Cannot find SSL libraries")
32
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080033 conf.load ('ccnx')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080034 conf.load('boost')
35
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080036 conf.check_boost(lib='system iostreams regex')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080037
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080038 boost_version = conf.env.BOOST_VERSION.split('_')
39 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
40 Logs.error ("Minumum required boost version is 1.46")
41 return
42
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080043 conf.check_ccnx (path=conf.options.ccnx_dir)
44
45 if conf.options.debug:
46 conf.define ('_DEBUG', 1)
47 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
48 else:
49 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
50
51 if conf.options._test:
52 conf.define('_TEST', 1)
53
54 conf.load('protobuf')
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):
59 bld.post_mode = Build.POST_LAZY
60
61 bld.add_group ("protobuf")
62
63# x = bld (
64# features = ["protobuf"],
65# source = ["model/sync-state.proto"],
66# target = ["model/sync-state.pb"],
67# )
68
69 bld.add_group ("code")
70
71 libccnx = bld (
Zhenkai Zhubad089c2012-12-28 10:28:27 -080072 target=CCNXLIB,
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080073 features=['cxx', 'cxxshlib'],
74 source = [
75 'src/ccnx-wrapper.cpp',
Zhenkai Zhubad089c2012-12-28 10:28:27 -080076 'src/ccnx-pco.cpp',
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080077 'src/ccnx-closure.cpp',
Zhenkai Zhud4924312012-12-28 11:35:12 -080078 'src/ccnx-tunnel.cpp',
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080079 ],
80 use = 'BOOST BOOST_THREAD SSL CCNX',
81 includes = ['include', ],
82 )
83
84 # Unit tests
85 if bld.get_define("_TEST"):
86 unittests = bld.program (
87 target="unit-tests",
88 source = bld.path.ant_glob(['test/**/*.cc']),
89 features=['cxx', 'cxxprogram'],
90 use = 'BOOST_TEST',
91 includes = ['include', ],
92 )
93
94
95
96
Zhenkai Zhu0a17aea2012-12-28 14:30:22 -080097
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080098 chronoshare = bld (
99 target=APPNAME,
100 features=['cxx', 'cxxprogram'],
101 # source = bld.path.ant_glob(['src/**/*.cc']),
102 source = ['src/main.cc', 'src/sqlite-helper.cc'],
103 use = 'BOOST BOOST_IOSTREAMS BOOST_REGEX CCNX SSL SQLITE3',
104 includes = ['include', 'src'],
105 )