blob: ce56610d77c50b256c0fb1de49f55651c0f7dbd6 [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 Afanasyev983b0e92012-04-26 12:44:18 -070010 opt.add_option('--ns3-debug', action='store_true',default=False,dest='ns3_debug',help='''Link against debug NS3 libraries. Optimized version will be used otherwise''')
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080011 opt.load('compiler_c')
12 opt.load('compiler_cxx')
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080013 opt.load('boost')
14 opt.load('doxygen')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070015 opt.load('ccnx tinyxml ns3', tooldir=["waf-tools"])
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080016
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080017def configure(conf):
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080018 conf.load("compiler_cxx")
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')
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070039 conf.define ('NS3_LOG_ENABLE', 1)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070040 else:
41 conf.check_boost(lib='system iostreams test thread')
42 conf.define ('STANDALONE', 1)
43
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070044 conf.load ('ccnx')
45 conf.check_ccnx (path=conf.options.ccnx_dir)
46
47 if conf.options.log4cxx:
48 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
49
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070050 if not conf.options.no_debug:
51 conf.define ('_DEBUG', 1)
Alexander Afanasyeva0c8a1d2012-04-05 13:55:42 -070052 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
53 else:
54 conf.env.append_value('CXXFLAGS', ['-O3'])
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070055
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080056 try:
57 conf.load('doxygen')
58 except:
59 pass
60
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070061 conf.load('tinyxml')
62 conf.check_tinyxml ()
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070063
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080064def build (bld):
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070065 if bld.get_define ("NS3_MODULE"):
66 sync_ns3 = bld.shlib (
67 target = "sync-ns3",
68 features=['cxx', 'cxxshlib'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070069 source = [
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070070 'ns3/sync-ccnx-wrapper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070071 'ns3/sync-ns3-name-info.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070072 'ns3/sync-scheduler.cc',
Alexander Afanasyev09e8d752012-04-10 16:05:55 -070073 'ns3/sync-logic-helper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070074
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070075 # 'model/sync-app-data-fetch.cc',
76 # 'model/sync-app-data-publish.cc',
77 # 'ns3/sync-app.cc',
78
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070079 'model/sync-diff-leaf.cc',
80 'model/sync-diff-state.cc',
81 'model/sync-digest.cc',
82 'model/sync-full-leaf.cc',
83 'model/sync-full-state.cc',
84 'model/sync-interest-table.cc',
85 'model/sync-leaf.cc',
86 'model/sync-logic.cc',
87 'model/sync-name-info.cc',
88 'model/sync-seq-no.cc',
89 'model/sync-state.cc',
90 'model/sync-std-name-info.cc',
91 ],
Alexander Afanasyevaced8ad2012-04-10 12:49:29 -070092 use = 'BOOST BOOST_IOSTREAMS SSL TINYXML ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (),
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070093 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070094 )
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070095
96 example = bld.program (
97 target = "sync-example",
98 features=['cxx', 'cxxprogram'],
99 source = ['examples/sync-example.cc'],
100 use = 'sync-ns3',
Alexander Afanasyevaced8ad2012-04-10 12:49:29 -0700101 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -0700102 )
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700103
104 sync_eval = bld.program (
105 target = "sync-eval",
106 features=['cxx', 'cxxprogram'],
107 source = ['evaluation/sync-eval.cc',
108 'evaluation/standard-muc.cc',
Alexander Afanasyev40942f42012-04-21 20:53:16 -0700109 'evaluation/sync-muc.cc',
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700110 ],
111 use = 'sync-ns3',
112 includes = ['model', 'ns3', 'helper'],
113 )
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700114 # from waflib import Utils,Logs,Errors
115 # Logs.pprint ('CYAN', program.use)
116
117 else:
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700118 libsync = bld.shlib (
119 target=APPNAME,
120 features=['cxx', 'cxxshlib'],
121 source = [
122 'ccnx/sync-ccnx-wrapper.cc',
123 'ccnx/sync-scheduler.cc',
124 'ccnx/sync-log.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -0700125 'ccnx/sync-app-data-fetch.cc',
126 'ccnx/sync-app-data-publish.cc',
127 'ccnx/sync-app-socket-c.cc',
128 'ccnx/sync-app-socket.cc',
Alexander Afanasyev181d7e52012-04-09 13:54:11 -0700129
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700130 'model/sync-diff-leaf.cc',
131 'model/sync-diff-state.cc',
132 'model/sync-digest.cc',
133 'model/sync-full-leaf.cc',
134 'model/sync-full-state.cc',
135 'model/sync-interest-table.cc',
136 'model/sync-leaf.cc',
137 'model/sync-logic.cc',
138 'model/sync-name-info.cc',
139 'model/sync-seq-no.cc',
140 'model/sync-state.cc',
141 'model/sync-std-name-info.cc',
142 ],
143 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX',
144 includes = ['model', 'ccnx', 'helper'],
145 )
146
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700147 # Unit tests
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700148 unittests = bld.program (
149 target="unit-tests",
150 source = bld.path.ant_glob(['test/**/*.cc']),
151 features=['cxx', 'cxxprogram'],
152 use = 'BOOST_TEST sync',
153 includes = ['model', 'ccnx', 'helper'],
154 )
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -0700155
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700156 if bld.get_define ("HAVE_LOG4CXX"):
157 libsync.use += ' LOG4CXX'
158 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800159
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800160# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800161from waflib.Build import BuildContext
162class doxy (BuildContext):
163 cmd = "doxygen"
164 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800165
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800166def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800167 if not bld.env.DOXYGEN:
168 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800169 bld (features="doxygen",
170 doxyfile='doc/doxygen.conf',
171 output_dir = 'doc')