blob: 88d47eef381e62cd1b39817eeff95fabcb784e0e [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
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070043 conf.load ('ccnx')
44 conf.check_ccnx (path=conf.options.ccnx_dir)
45
46 if conf.options.log4cxx:
47 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
48
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070049 if not conf.options.no_debug:
50 conf.define ('_DEBUG', 1)
51
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080052 try:
53 conf.load('doxygen')
54 except:
55 pass
56
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070057 conf.load('tinyxml')
58 conf.check_tinyxml ()
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080059
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070060 # else:
61 # if 'CXXFLAGS' in conf.env:
62 # tmp = conf.env['CXXFLAGS']
63 # else:
64 # tmp = []
65 # conf.env['CXXFLAGS'] = tmp + ['-g']
66 # if 'CFLAGS' in conf.env:
67 # tmp = conf.env['CFLAGS']
68 # else:
69 # tmp = []
70 # conf.env['CFLAGS'] = tmp + ['-g']
71 # _report_optional_feature(conf, "debug", "Debug Symbols", True, '')
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070072
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070073
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080074def build (bld):
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070075 if bld.get_define ("NS3_MODULE"):
76 sync_ns3 = bld.shlib (
77 target = "sync-ns3",
78 features=['cxx', 'cxxshlib'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070079 source = [
80 # 'ns3/sync-ccnx-wrapper.cc',
81 'ns3/sync-ns3-name-info.cc',
82
83 'model/sync-app-data-fetch.cc',
84 'model/sync-app-data-publish.cc',
85 'model/sync-app-socket-c.cc',
86 'model/sync-app-socket.cc',
87 'model/sync-diff-leaf.cc',
88 'model/sync-diff-state.cc',
89 'model/sync-digest.cc',
90 'model/sync-full-leaf.cc',
91 'model/sync-full-state.cc',
92 'model/sync-interest-table.cc',
93 'model/sync-leaf.cc',
94 'model/sync-logic.cc',
95 'model/sync-name-info.cc',
96 'model/sync-seq-no.cc',
97 'model/sync-state.cc',
98 'model/sync-std-name-info.cc',
99 ],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700100 use = 'BOOST BOOST_IOSTREAMS SSL TINYXML CCNX ' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'NDNabstraction']]).upper (),
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700101 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700102 )
103
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700104 # from waflib import Utils,Logs,Errors
105 # Logs.pprint ('CYAN', program.use)
106
107 else:
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700108 libsync = bld.shlib (
109 target=APPNAME,
110 features=['cxx', 'cxxshlib'],
111 source = [
112 'ccnx/sync-ccnx-wrapper.cc',
113 'ccnx/sync-scheduler.cc',
114 'ccnx/sync-log.cc',
115
116 'model/sync-app-data-fetch.cc',
117 'model/sync-app-data-publish.cc',
118 'model/sync-app-socket-c.cc',
119 'model/sync-app-socket.cc',
120 'model/sync-diff-leaf.cc',
121 'model/sync-diff-state.cc',
122 'model/sync-digest.cc',
123 'model/sync-full-leaf.cc',
124 'model/sync-full-state.cc',
125 'model/sync-interest-table.cc',
126 'model/sync-leaf.cc',
127 'model/sync-logic.cc',
128 'model/sync-name-info.cc',
129 'model/sync-seq-no.cc',
130 'model/sync-state.cc',
131 'model/sync-std-name-info.cc',
132 ],
133 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX',
134 includes = ['model', 'ccnx', 'helper'],
135 )
136
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700137 # Unit tests
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700138 unittests = bld.program (
139 target="unit-tests",
140 source = bld.path.ant_glob(['test/**/*.cc']),
141 features=['cxx', 'cxxprogram'],
142 use = 'BOOST_TEST sync',
143 includes = ['model', 'ccnx', 'helper'],
144 )
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -0700145
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700146 if bld.get_define ("HAVE_LOG4CXX"):
147 libsync.use += ' LOG4CXX'
148 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800149
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800150# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800151from waflib.Build import BuildContext
152class doxy (BuildContext):
153 cmd = "doxygen"
154 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800155
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800156def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800157 if not bld.env.DOXYGEN:
158 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800159 bld (features="doxygen",
160 doxyfile='doc/doxygen.conf',
161 output_dir = 'doc')