blob: ade425a623d3bc70ffedb56bc6dd769969a620cf [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 Afanasyev0ad7c212012-04-05 13:31:14 -07008 opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx/native NS3 logging support''')
9 opt.add_option('--ns3', action='store_true',default=False,dest='ns3_enable',help='''Compile as NS-3 module''')
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080010 opt.load('compiler_c')
11 opt.load('compiler_cxx')
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080012 opt.load('boost')
13 opt.load('doxygen')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070014 opt.load('ccnx tinyxml ns3', tooldir=["waf-tools"])
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080015
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080016def configure(conf):
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080017 conf.load("compiler_cxx")
Chaoyi Bian98135192012-03-27 18:34:11 -070018 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080019
20 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
21 libcrypto = conf.check_cc(lib='crypto',
22 header_name='openssl/crypto.h',
23 define_name='HAVE_SSL',
24 uselib_store='SSL')
25 if not conf.get_define ("HAVE_SSL"):
26 conf.fatal ("Cannot find SSL libraries")
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080027
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080028 conf.load('boost')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070029
30 if conf.options.ns3_enable:
31 conf.load('ns3')
32 conf.define('NS3_MODULE', 1)
33 conf.check_modules(['core', 'network', 'internet'], mandatory = True)
34 conf.check_modules(['NDNabstraction'], mandatory = True)
35 conf.check_modules(['point-to-point'], mandatory = False)
36 conf.check_modules(['point-to-point-layout'], mandatory = False)
37
38 conf.check_boost(lib='system iostreams thread')
39 else:
40 conf.check_boost(lib='system iostreams test thread')
41 conf.define ('STANDALONE', 1)
42
43 if not conf.options.no_debug:
44 conf.define ('_DEBUG', 1)
45
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080046
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080047 try:
48 conf.load('doxygen')
49 except:
50 pass
51
Alexander Afanasyev250a4c42012-03-07 13:40:18 -080052 conf.load('ccnx tinyxml')
53 conf.check_ccnx (path=conf.options.ccnx_dir)
54 conf.check_tinyxml (path=conf.options.ccnx_dir)
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080055
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070056 # else:
57 # if 'CXXFLAGS' in conf.env:
58 # tmp = conf.env['CXXFLAGS']
59 # else:
60 # tmp = []
61 # conf.env['CXXFLAGS'] = tmp + ['-g']
62 # if 'CFLAGS' in conf.env:
63 # tmp = conf.env['CFLAGS']
64 # else:
65 # tmp = []
66 # conf.env['CFLAGS'] = tmp + ['-g']
67 # _report_optional_feature(conf, "debug", "Debug Symbols", True, '')
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070068
69 if conf.options.log4cxx:
70 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
71
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080072def build (bld):
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070073 if bld.get_define ("NS3_MODULE"):
74 sync_ns3 = bld.shlib (
75 target = "sync-ns3",
76 features=['cxx', 'cxxshlib'],
77 use = 'BOOST BOOST_IOSTREAMS SSL TINYXML CCNX ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (),
78 source = bld.path.ant_glob(['model/sync-*.cc',
79 'helper/sync-*.cc']),
80 )
81
82
83 # from waflib import Utils,Logs,Errors
84 # Logs.pprint ('CYAN', program.use)
85
86 else:
87 libsync = bld.shlib (target=APPNAME,
88 features=['cxx', 'cxxshlib'],
89 source = bld.path.ant_glob(['model/sync-*.cc',
90 'helper/sync-*.cc']),
91 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX')
Alexander Afanasyevec1d4a72012-03-05 11:06:54 -080092
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070093 # Unit tests
94 unittests = bld.program (target="unit-tests",
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070095 source = bld.path.ant_glob(['test/**/*.cc']),
96 features=['cxx', 'cxxprogram'],
97 use = 'BOOST_TEST sync')
98
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070099 if bld.get_define ("HAVE_LOG4CXX"):
100 libsync.use += ' LOG4CXX'
101 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800102
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800103# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800104from waflib.Build import BuildContext
105class doxy (BuildContext):
106 cmd = "doxygen"
107 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800108
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800109def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800110 if not bld.env.DOXYGEN:
111 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800112 bld (features="doxygen",
113 doxyfile='doc/doxygen.conf',
114 output_dir = 'doc')