blob: df97940a81abe86fdb79cd8887cab479f7c67489 [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')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070043
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
Zhenkai Zhu699d7402012-05-29 16:47:39 -070050 if conf.options.debug:
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070051 conf.define ('_DEBUG', 1)
Alexander Afanasyeva0c8a1d2012-04-05 13:55:42 -070052 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
53 else:
Zhenkai Zhudc70a292012-06-01 14:00:59 -070054 conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070055
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -070056 if conf.options._test:
57 conf.define('_TEST', 1)
58
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080059 try:
60 conf.load('doxygen')
61 except:
62 pass
63
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070064 conf.load('tinyxml')
65 conf.check_tinyxml ()
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070066
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080067def build (bld):
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070068 if bld.get_define ("NS3_MODULE"):
69 sync_ns3 = bld.shlib (
70 target = "sync-ns3",
71 features=['cxx', 'cxxshlib'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070072 source = [
Alexander Afanasyev181d7e52012-04-09 13:54:11 -070073 'ns3/sync-ccnx-wrapper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070074 'ns3/sync-ns3-name-info.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070075 'ns3/sync-scheduler.cc',
Alexander Afanasyev09e8d752012-04-10 16:05:55 -070076 'ns3/sync-logic-helper.cc',
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070077
Alexander Afanasyevca6f3292012-04-09 10:03:30 -070078 # 'model/sync-app-data-fetch.cc',
79 # 'model/sync-app-data-publish.cc',
80 # 'ns3/sync-app.cc',
81
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070082 'model/sync-diff-leaf.cc',
83 'model/sync-diff-state.cc',
84 'model/sync-digest.cc',
85 'model/sync-full-leaf.cc',
86 'model/sync-full-state.cc',
87 'model/sync-interest-table.cc',
88 'model/sync-leaf.cc',
89 'model/sync-logic.cc',
90 'model/sync-name-info.cc',
91 'model/sync-seq-no.cc',
92 'model/sync-state.cc',
93 'model/sync-std-name-info.cc',
94 ],
Alexander Afanasyevaced8ad2012-04-10 12:49:29 -070095 use = 'BOOST BOOST_IOSTREAMS SSL TINYXML ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (),
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -070096 includes = ['include', 'include/ns3', 'helper'],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070097 )
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -070098
99 example = bld.program (
100 target = "sync-example",
101 features=['cxx', 'cxxprogram'],
102 source = ['examples/sync-example.cc'],
103 use = 'sync-ns3',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700104 includes = ['include', 'include/ns3', 'helper'],
Alexander Afanasyevb550d6a2012-04-09 15:03:16 -0700105 )
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700106
107 sync_eval = bld.program (
108 target = "sync-eval",
109 features=['cxx', 'cxxprogram'],
110 source = ['evaluation/sync-eval.cc',
111 'evaluation/standard-muc.cc',
Alexander Afanasyev40942f42012-04-21 20:53:16 -0700112 'evaluation/sync-muc.cc',
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700113 ],
114 use = 'sync-ns3',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700115 includes = ['include', 'include/ns3', 'helper'],
Alexander Afanasyevd7fc7c02012-04-19 15:36:26 -0700116 )
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700117 # from waflib import Utils,Logs,Errors
118 # Logs.pprint ('CYAN', program.use)
119
120 else:
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700121 libsync = bld.shlib (
122 target=APPNAME,
123 features=['cxx', 'cxxshlib'],
124 source = [
125 'ccnx/sync-ccnx-wrapper.cc',
126 'ccnx/sync-scheduler.cc',
127 'ccnx/sync-log.cc',
Chaoyi Bian2f2d6412012-06-04 16:53:08 -0700128 'ccnx/sync-app-socket-c.cc',
Alexander Afanasyevca6f3292012-04-09 10:03:30 -0700129 'ccnx/sync-app-socket.cc',
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',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700144 includes = ['include', 'helper'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700145 )
146
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700147 # Unit tests
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -0700148 if bld.get_define("_TEST"):
149 unittests = bld.program (
150 target="unit-tests",
151 source = bld.path.ant_glob(['test/**/*.cc']),
152 features=['cxx', 'cxxprogram'],
153 use = 'BOOST_TEST sync',
Zhenkai Zhu9ec8f412012-06-01 15:44:36 -0700154 includes = ['include', 'helper'],
Zhenkai Zhu43ae5c72012-05-31 23:18:45 -0700155 )
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -0700156
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700157 if bld.get_define ("HAVE_LOG4CXX"):
158 libsync.use += ' LOG4CXX'
159 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800160
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800161# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800162from waflib.Build import BuildContext
163class doxy (BuildContext):
164 cmd = "doxygen"
165 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800166
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800167def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800168 if not bld.env.DOXYGEN:
169 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800170 bld (features="doxygen",
171 doxyfile='doc/doxygen.conf',
172 output_dir = 'doc')