blob: 560f1fe9f2d227f6c8aa96136f5272d786fd536f [file] [log] [blame]
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev7804c232013-07-14 12:15:41 -07003VERSION='0.1'
4APPNAME='ChronoSync'
Alexander Afanasyev182fdc22012-03-05 18:06:52 -08005
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -07006from waflib import Configure, Build, Logs
Alexander Afanasyev6af3c152012-06-07 21:14:24 -07007
Alexander Afanasyeve76f2632012-03-05 00:18:42 -08008def options(opt):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -07009 opt.load('compiler_c compiler_cxx boost doxygen gnu_dirs protoc')
Yingdi Yu43e71612013-10-30 22:19:31 -070010 # opt.load('ndnx', tooldir=["waf-tools"])
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070011
12 syncopt = opt.add_option_group ("ChronoSync Options")
13
14 syncopt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
15 syncopt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx''')
16 syncopt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080017
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080018def configure(conf):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070019 conf.load('compiler_c compiler_cxx gnu_dirs boost')
Yingdi Yu43e71612013-10-30 22:19:31 -070020 # conf.load('ndnx')
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070021
Zhenkai Zhu699d7402012-05-29 16:47:39 -070022 if conf.options.debug:
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070023 conf.define ('_DEBUG', 1)
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070024 conf.add_supported_cxxflags (cxxflags = ['-O0',
25 '-Wall',
26 '-Wno-unused-variable',
27 '-g3',
28 '-Wno-unused-private-field', # only clang supports
29 '-fcolor-diagnostics', # only clang supports
30 '-Qunused-arguments' # only clang supports
31 ])
Alexander Afanasyeva0c8a1d2012-04-05 13:55:42 -070032 else:
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070033 conf.add_supported_cxxflags (cxxflags = ['-O3', '-g'])
34
Yingdi Yu43e71612013-10-30 22:19:31 -070035 # conf.check_ndnx ()
36
37 conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True)
38 conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='OPENSSL', mandatory=True)
39 # conf.check_openssl ()
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070040
41 conf.check_boost(lib='system iostreams test thread')
42
43 if conf.options.log4cxx:
44 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070045
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070046 if conf.options._test:
47 conf.define('_TEST', 1)
48
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080049 try:
50 conf.load('doxygen')
51 except:
52 pass
53
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070054 conf.load('protoc')
Zhenkai Zhu3cfdcb92012-06-06 15:20:10 -070055
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080056def build (bld):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070057 libsync = bld (
Alexander Afanasyevf46eac52013-07-26 11:27:39 -070058 target="ChronoSync",
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070059 features=['cxx', 'cxxshlib'],
Alexander Afanasyevce001692013-07-14 11:34:41 -070060 source = bld.path.ant_glob (['src/**/*.cc', 'src/**/*.proto']),
Yingdi Yu43e71612013-10-30 22:19:31 -070061 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL NDNCXX OPENSSL',
Alexander Afanasyevce001692013-07-14 11:34:41 -070062 includes = ['src'],
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070063 )
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070064
65 # Unit tests
66 if bld.get_define("_TEST"):
67 unittests = bld.program (
68 target="unit-tests",
69 source = bld.path.ant_glob(['tests/**/*.cc']),
70 features=['cxx', 'cxxprogram'],
Alexander Afanasyevf46eac52013-07-26 11:27:39 -070071 use = 'BOOST_TEST ChronoSync',
Alexander Afanasyevce001692013-07-14 11:34:41 -070072 includes = ['src'],
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070073 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -070074
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070075 if bld.get_define ("HAVE_LOG4CXX"):
76 libsync.use += ' LOG4CXX'
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070077 if bld.get_define("_TEST"):
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070078 unittests.use += ' LOG4CXX'
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070079
Alexander Afanasyevce001692013-07-14 11:34:41 -070080 bld.install_files (
81 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
82 files = bld.path.ant_glob(['src/**/*.h']),
83 cwd = bld.path.find_dir ("src"),
84 relative_trick = True,
85 )
86
87 bld.install_files (
88 dest = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
89 files = bld.path.get_bld().ant_glob(['src/**/*.h']),
90 cwd = bld.path.get_bld().find_dir ("src"),
91 relative_trick = True,
92 )
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080093
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070094 pc = bld (
95 features = "subst",
Alexander Afanasyev7804c232013-07-14 12:15:41 -070096 source='ChronoSync.pc.in',
97 target='ChronoSync.pc',
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -070098 install_path = '${LIBDIR}/pkgconfig',
99 PREFIX = bld.env['PREFIX'],
Alexander Afanasyevce001692013-07-14 11:34:41 -0700100 INCLUDEDIR = "%s/ChronoSync" % bld.env['INCLUDEDIR'],
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -0700101 VERSION = VERSION,
102 )
Alexander Afanasyev6af3c152012-06-07 21:14:24 -0700103
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800104# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800105from waflib.Build import BuildContext
106class doxy (BuildContext):
107 cmd = "doxygen"
108 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800109
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800110def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800111 if not bld.env.DOXYGEN:
112 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800113 bld (features="doxygen",
114 doxyfile='doc/doxygen.conf',
115 output_dir = 'doc')
Alexander Afanasyev6133f9a2013-07-14 10:58:26 -0700116
117@Configure.conf
118def add_supported_cxxflags(self, cxxflags):
119 """
120 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
121 """
122 self.start_msg('Checking allowed flags for c++ compiler')
123
124 supportedFlags = []
125 for flag in cxxflags:
126 if self.check_cxx (cxxflags=[flag], mandatory=False):
127 supportedFlags += [flag]
128
129 self.end_msg (' '.join (supportedFlags))
130 self.env.CXXFLAGS += supportedFlags