blob: 8c52b8b75f332e00d28b0b5a3d32f309e1368456 [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):
Zhenkai Zhu699d7402012-05-29 16:47:39 -07007 opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
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''')
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070011 opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080012 opt.load('compiler_c')
13 opt.load('compiler_cxx')
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080014 opt.load('boost')
15 opt.load('doxygen')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070016 opt.load('ccnx tinyxml ns3', tooldir=["waf-tools"])
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080017
Alexander Afanasyev8f25cbb2012-03-01 23:53:40 -080018def configure(conf):
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080019 conf.load("compiler_cxx")
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080020
21 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
22 libcrypto = conf.check_cc(lib='crypto',
23 header_name='openssl/crypto.h',
24 define_name='HAVE_SSL',
25 uselib_store='SSL')
26 if not conf.get_define ("HAVE_SSL"):
27 conf.fatal ("Cannot find SSL libraries")
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080028
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080029 conf.load('boost')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070030
31 if conf.options.ns3_enable:
32 conf.load('ns3')
33 conf.define('NS3_MODULE', 1)
34 conf.check_modules(['core', 'network', 'internet'], mandatory = True)
35 conf.check_modules(['NDNabstraction'], mandatory = True)
36 conf.check_modules(['point-to-point'], mandatory = False)
37 conf.check_modules(['point-to-point-layout'], mandatory = False)
38
39 conf.check_boost(lib='system iostreams thread')
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070040 conf.define ('NS3_LOG_ENABLE', 1)
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070041 else:
42 conf.check_boost(lib='system iostreams test thread')
43 conf.define ('STANDALONE', 1)
44
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070045 conf.load ('ccnx')
46 conf.check_ccnx (path=conf.options.ccnx_dir)
47
48 if conf.options.log4cxx:
49 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
50
Zhenkai Zhu699d7402012-05-29 16:47:39 -070051 if conf.options.debug:
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070052 conf.define ('_DEBUG', 1)
Alexander Afanasyeva0c8a1d2012-04-05 13:55:42 -070053 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
54 else:
55 conf.env.append_value('CXXFLAGS', ['-O3'])
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070056
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070057 if conf.options._test:
58 conf.define('_TEST', 1)
59
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080060 try:
61 conf.load('doxygen')
62 except:
63 pass
64
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070065 conf.load('tinyxml')
66 conf.check_tinyxml ()
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070067
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080068def build (bld):
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070069 if bld.get_define ("NS3_MODULE"):
70 sync_ns3 = bld.shlib (
71 target = "sync-ns3",
72 features=['cxx', 'cxxshlib'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070073 source = [
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070074 'ns3/sync-ccnx-wrapper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070075 'ns3/sync-ns3-name-info.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070076 'ns3/sync-scheduler.cc',
Alexander Afanasyev09e8d752012-04-10 16:05:55 -070077 'ns3/sync-logic-helper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070078
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070079 # 'model/sync-app-data-fetch.cc',
80 # 'model/sync-app-data-publish.cc',
81 # 'ns3/sync-app.cc',
82
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070083 'model/sync-diff-leaf.cc',
84 'model/sync-diff-state.cc',
85 'model/sync-digest.cc',
86 'model/sync-full-leaf.cc',
87 'model/sync-full-state.cc',
88 'model/sync-interest-table.cc',
89 'model/sync-leaf.cc',
90 'model/sync-logic.cc',
91 'model/sync-name-info.cc',
92 'model/sync-seq-no.cc',
93 'model/sync-state.cc',
94 'model/sync-std-name-info.cc',
95 ],
Alexander Afanasyevaced8ad2012-04-10 12:49:29 -070096 use = 'BOOST BOOST_IOSTREAMS SSL TINYXML ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (),
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070097 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070098 )
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070099
100 example = bld.program (
101 target = "sync-example",
102 features=['cxx', 'cxxprogram'],
103 source = ['examples/sync-example.cc'],
104 use = 'sync-ns3',
Alexander Afanasyevaced8ad2012-04-10 12:49:29 -0700105 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -0700106 )
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700107
108 sync_eval = bld.program (
109 target = "sync-eval",
110 features=['cxx', 'cxxprogram'],
111 source = ['evaluation/sync-eval.cc',
112 'evaluation/standard-muc.cc',
Alexander Afanasyev40942f42012-04-21 20:53:16 -0700113 'evaluation/sync-muc.cc',
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700114 ],
115 use = 'sync-ns3',
116 includes = ['model', 'ns3', 'helper'],
117 )
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700118 # from waflib import Utils,Logs,Errors
119 # Logs.pprint ('CYAN', program.use)
120
121 else:
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700122 libsync = bld.shlib (
123 target=APPNAME,
124 features=['cxx', 'cxxshlib'],
125 source = [
126 'ccnx/sync-ccnx-wrapper.cc',
127 'ccnx/sync-scheduler.cc',
128 'ccnx/sync-log.cc',
Zhenkai Zhu1cb29292012-05-31 22:54:34 -0700129 #'ccnx/sync-app-data-fetch.cc',
130 #'ccnx/sync-app-data-publish.cc',
131 #'ccnx/sync-app-socket-c.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -0700132 'ccnx/sync-app-socket.cc',
Alexander Afanasyev181d7e52012-04-09 13:54:11 -0700133
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700134 'model/sync-diff-leaf.cc',
135 'model/sync-diff-state.cc',
136 'model/sync-digest.cc',
137 'model/sync-full-leaf.cc',
138 'model/sync-full-state.cc',
139 'model/sync-interest-table.cc',
140 'model/sync-leaf.cc',
141 'model/sync-logic.cc',
142 'model/sync-name-info.cc',
143 'model/sync-seq-no.cc',
144 'model/sync-state.cc',
145 'model/sync-std-name-info.cc',
146 ],
147 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX',
148 includes = ['model', 'ccnx', 'helper'],
149 )
150
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700151 # Unit tests
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -0700152 if bld.get_define("_TEST"):
153 unittests = bld.program (
154 target="unit-tests",
155 source = bld.path.ant_glob(['test/**/*.cc']),
156 features=['cxx', 'cxxprogram'],
157 use = 'BOOST_TEST sync',
158 includes = ['model', 'ccnx', 'helper'],
159 )
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -0700160
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700161 if bld.get_define ("HAVE_LOG4CXX"):
162 libsync.use += ' LOG4CXX'
163 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800164
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800165# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800166from waflib.Build import BuildContext
167class doxy (BuildContext):
168 cmd = "doxygen"
169 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800170
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800171def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800172 if not bld.env.DOXYGEN:
173 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800174 bld (features="doxygen",
175 doxyfile='doc/doxygen.conf',
176 output_dir = 'doc')