blob: 49ab31f54509f32a78a6eb222f33bbbcbd07d589 [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'
5
6from waflib import Build, Logs
7
8def options(opt):
9 opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
10 opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080011 opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080012
Alexander Afanasyev33206982013-01-09 16:29:29 -080013 opt.load('compiler_cxx boost ccnx protoc ice_cxx qt4')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080014
15def configure(conf):
16 conf.load("compiler_cxx")
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080017
Alexander Afanasyevf2890632013-01-02 13:40:02 -080018 conf.define ("CHRONOSHARE_VERSION", VERSION)
19
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080020 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080021 conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True)
22 conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', 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')
Alexander Afanasyev33206982013-01-09 16:29:29 -080035
36 conf.load('protoc')
37 conf.load('ice_cxx')
38
39 conf.load('qt4')
40
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080041 conf.load('boost')
42
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080043 conf.check_boost(lib='system test iostreams filesystem regex thread')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080044
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080045 boost_version = conf.env.BOOST_VERSION.split('_')
46 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
47 Logs.error ("Minumum required boost version is 1.46")
48 return
49
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080050 conf.check_ccnx (path=conf.options.ccnx_dir)
51
52 if conf.options.debug:
53 conf.define ('_DEBUG', 1)
Alexander Afanasyevd09871f2013-01-04 22:36:37 -080054 conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-fcolor-diagnostics', '-g3'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080055 else:
56 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
57
58 if conf.options._test:
Alexander Afanasyev72ac2192013-01-03 19:33:43 -080059 conf.env.TEST = 1
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080060
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080061 conf.write_config_header('src/config.h')
62
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080063def build (bld):
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080064 scheduler = bld.objects (
65 target = "scheduler",
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080066 features = ["cxx"],
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080067 source = bld.path.ant_glob(['scheduler/**/*.cc']),
68 use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS',
69 includes = ['scheduler'],
Alexander Afanasyev68f2a952013-01-08 14:34:16 -080070 )
71
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080072 libccnx = bld (
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080073 target="ccnx",
74 features=['cxx'],
75 source = bld.path.ant_glob(['ccnx/**/*.cc', 'ccnx/**/*.cpp']),
76 use = 'BOOST BOOST_THREAD SSL CCNX scheduler',
77 includes = ['ccnx', 'scheduler'],
Alexander Afanasyevf2890632013-01-02 13:40:02 -080078 )
79
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080080 chornoshare = bld (
81 target="chronoshare",
82 features=['cxx'],
83 source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']),
Alexander Afanasyevabe952a2013-01-17 17:06:32 -080084 use = "BOOST BOOST_FILESYSTEM SQLITE3 scheduler ccnx",
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080085 includes = "ccnx scheduler src",
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080086 )
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080087
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080088 # Unit tests
89 if bld.env['TEST']:
90 unittests = bld.program (
91 target="unit-tests",
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080092 source = bld.path.ant_glob(['test/*.cc']),
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080093 features=['cxx', 'cxxprogram'],
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -080094 use = 'BOOST_TEST BOOST_FILESYSTEM ccnx database chronoshare',
95 includes = "ccnx scheduler src",
Alexander Afanasyevee7e6132013-01-03 20:03:14 -080096 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -080097
Alexander Afanasyevabe952a2013-01-17 17:06:32 -080098 qt = bld (
99 target = "filewatcher",
100 features = "qt4 cxx cxxprogram",
101 defines = "WAF",
102 source = bld.path.ant_glob(['filesystemwatcher/*.cpp']),
103 includes = "filesystemwatcher . ",
104 use = "QTCORE QTGUI"
105 )
Jared Lindblomdc845f02013-01-18 17:29:40 -0800106
107 qt = bld (
108 target = "gui",
109 features = "qt4 cxx cxxprogram",
110 defines = "WAF",
111 source = bld.path.ant_glob(['gui/*.cpp']),
Alexander Afanasyevfb4c43f2013-01-18 17:43:25 -0800112 includes = "gui . ",
Jared Lindblomdc845f02013-01-18 17:29:40 -0800113 use = "QTCORE QTGUI"
114 )