blob: 6a0a6290799b92808653d575f7ab52de493e6c19 [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 Afanasyev182fdc22012-03-05 18:06:52 -08003VERSION='0.0.1'
4APPNAME='sync'
5
Alexander Afanasyeve76f2632012-03-05 00:18:42 -08006def options(opt):
Alexander Afanasyev87c9b5d2012-03-07 17:23:21 -08007 opt.add_option('--no-debug',action='store_true',default=False,dest='no_debug',help='''Make an optimized build of the library (remove debugging code)''')
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -07008 opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx support''')
Alexander Afanasyeve76f2632012-03-05 00:18:42 -08009 opt.load('compiler_c')
10 opt.load('compiler_cxx')
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080011 opt.load('boost')
12 opt.load('doxygen')
Alexander Afanasyev250a4c42012-03-07 13:40:18 -080013 opt.load('ccnx tinyxml', tooldir=["waf-tools"])
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080014
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080015def configure(conf):
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080016 conf.load("compiler_cxx")
Chaoyi Bian98135192012-03-27 18:34:11 -070017 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080018
19 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
20 libcrypto = conf.check_cc(lib='crypto',
21 header_name='openssl/crypto.h',
22 define_name='HAVE_SSL',
23 uselib_store='SSL')
24 if not conf.get_define ("HAVE_SSL"):
25 conf.fatal ("Cannot find SSL libraries")
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080026
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080027 conf.load('boost')
Chaoyi Bianee5b8842012-03-07 13:43:27 -080028 conf.check_boost(lib='system iostreams test thread')
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080029
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080030 try:
31 conf.load('doxygen')
32 except:
33 pass
34
Alexander Afanasyev250a4c42012-03-07 13:40:18 -080035 conf.load('ccnx tinyxml')
36 conf.check_ccnx (path=conf.options.ccnx_dir)
37 conf.check_tinyxml (path=conf.options.ccnx_dir)
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080038
Alexander Afanasyev250a4c42012-03-07 13:40:18 -080039 conf.define ('STANDALONE', 1)
Alexander Afanasyev87c9b5d2012-03-07 17:23:21 -080040 if not conf.options.no_debug:
41 conf.define ('_DEBUG', 1)
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070042
43 if conf.options.log4cxx:
44 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
45
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080046def build (bld):
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070047 libsync = bld.shlib (target=APPNAME,
48 features=['cxx', 'cxxshlib'],
49 source = bld.path.ant_glob(['model/sync-*.cc',
50 'helper/sync-*.cc']),
51 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX')
Alexander Afanasyevec1d4a72012-03-05 11:06:54 -080052
Alexander Afanasyev150f14d2012-03-05 21:24:49 -080053 # Unit tests
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070054 unittests = bld.program (target="unit-tests",
55 source = bld.path.ant_glob(['test/**/*.cc']),
56 features=['cxx', 'cxxprogram'],
57 use = 'BOOST_TEST sync')
58
59 if bld.get_define ("HAVE_LOG4CXX"):
60 libsync.use += ' LOG4CXX'
61 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080062
Alexander Afanasyev150f14d2012-03-05 21:24:49 -080063# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080064from waflib.Build import BuildContext
65class doxy (BuildContext):
66 cmd = "doxygen"
67 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080068
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080069def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080070 if not bld.env.DOXYGEN:
71 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080072 bld (features="doxygen",
73 doxyfile='doc/doxygen.conf',
74 output_dir = 'doc')