blob: 6f5667d2985bbf64e658f0d5253a7c71a7ad4d46 [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")
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080018
19 if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
20 libcrypto = conf.check_cc(lib='crypto',
21 header_name='openssl/crypto.h',
22 define_name='HAVE_SSL',
23 uselib_store='SSL')
24 if not conf.get_define ("HAVE_SSL"):
25 conf.fatal ("Cannot find SSL libraries")
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080026
Alexander Afanasyev182fdc22012-03-05 18:06:52 -080027 conf.load('boost')
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070028
29 if conf.options.ns3_enable:
30 conf.load('ns3')
31 conf.define('NS3_MODULE', 1)
32 conf.check_modules(['core', 'network', 'internet'], mandatory = True)
33 conf.check_modules(['NDNabstraction'], mandatory = True)
34 conf.check_modules(['point-to-point'], mandatory = False)
35 conf.check_modules(['point-to-point-layout'], mandatory = False)
36
37 conf.check_boost(lib='system iostreams thread')
38 else:
39 conf.check_boost(lib='system iostreams test thread')
40 conf.define ('STANDALONE', 1)
41
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070042 conf.load ('ccnx')
43 conf.check_ccnx (path=conf.options.ccnx_dir)
44
45 if conf.options.log4cxx:
46 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
47
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070048 if not conf.options.no_debug:
49 conf.define ('_DEBUG', 1)
Alexander Afanasyeva0c8a1d2012-04-05 13:55:42 -070050 conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
51 else:
52 conf.env.append_value('CXXFLAGS', ['-O3'])
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070053
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -080054 try:
55 conf.load('doxygen')
56 except:
57 pass
58
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070059 conf.load('tinyxml')
60 conf.check_tinyxml ()
Alexander Afanasyeve76f2632012-03-05 00:18:42 -080061
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070062 # else:
63 # if 'CXXFLAGS' in conf.env:
64 # tmp = conf.env['CXXFLAGS']
65 # else:
66 # tmp = []
67 # conf.env['CXXFLAGS'] = tmp + ['-g']
68 # if 'CFLAGS' in conf.env:
69 # tmp = conf.env['CFLAGS']
70 # else:
71 # tmp = []
72 # conf.env['CFLAGS'] = tmp + ['-g']
73 # _report_optional_feature(conf, "debug", "Debug Symbols", True, '')
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070074
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -070075
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -080076def build (bld):
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -070077 if bld.get_define ("NS3_MODULE"):
78 sync_ns3 = bld.shlib (
79 target = "sync-ns3",
80 features=['cxx', 'cxxshlib'],
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -070081 source = [
82 # 'ns3/sync-ccnx-wrapper.cc',
83 'ns3/sync-ns3-name-info.cc',
84
85 'model/sync-app-data-fetch.cc',
86 'model/sync-app-data-publish.cc',
87 'model/sync-app-socket-c.cc',
88 'model/sync-app-socket.cc',
89 'model/sync-diff-leaf.cc',
90 'model/sync-diff-state.cc',
91 'model/sync-digest.cc',
92 'model/sync-full-leaf.cc',
93 'model/sync-full-state.cc',
94 'model/sync-interest-table.cc',
95 'model/sync-leaf.cc',
96 'model/sync-logic.cc',
97 'model/sync-name-info.cc',
98 'model/sync-seq-no.cc',
99 'model/sync-state.cc',
100 'model/sync-std-name-info.cc',
101 ],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700102 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 -0700103 includes = ['model', 'ns3', 'helper'],
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700104 )
105
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700106 # from waflib import Utils,Logs,Errors
107 # Logs.pprint ('CYAN', program.use)
108
109 else:
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700110 libsync = bld.shlib (
111 target=APPNAME,
112 features=['cxx', 'cxxshlib'],
113 source = [
114 'ccnx/sync-ccnx-wrapper.cc',
115 'ccnx/sync-scheduler.cc',
116 'ccnx/sync-log.cc',
117
118 'model/sync-app-data-fetch.cc',
119 'model/sync-app-data-publish.cc',
120 'model/sync-app-socket-c.cc',
121 'model/sync-app-socket.cc',
122 'model/sync-diff-leaf.cc',
123 'model/sync-diff-state.cc',
124 'model/sync-digest.cc',
125 'model/sync-full-leaf.cc',
126 'model/sync-full-state.cc',
127 'model/sync-interest-table.cc',
128 'model/sync-leaf.cc',
129 'model/sync-logic.cc',
130 'model/sync-name-info.cc',
131 'model/sync-seq-no.cc',
132 'model/sync-state.cc',
133 'model/sync-std-name-info.cc',
134 ],
135 use = 'BOOST BOOST_IOSTREAMS BOOST_THREAD SSL TINYXML CCNX',
136 includes = ['model', 'ccnx', 'helper'],
137 )
138
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700139 # Unit tests
Alexander Afanasyev158ec0d2012-04-05 13:48:55 -0700140 unittests = bld.program (
141 target="unit-tests",
142 source = bld.path.ant_glob(['test/**/*.cc']),
143 features=['cxx', 'cxxprogram'],
144 use = 'BOOST_TEST sync',
145 includes = ['model', 'ccnx', 'helper'],
146 )
Alexander Afanasyev4f9ea482012-03-15 11:57:29 -0700147
Alexander Afanasyev0ad7c212012-04-05 13:31:14 -0700148 if bld.get_define ("HAVE_LOG4CXX"):
149 libsync.use += ' LOG4CXX'
150 unittests.use += ' LOG4CXX'
Alexander Afanasyeve76f2632012-03-05 00:18:42 -0800151
Alexander Afanasyev150f14d2012-03-05 21:24:49 -0800152# doxygen docs
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800153from waflib.Build import BuildContext
154class doxy (BuildContext):
155 cmd = "doxygen"
156 fun = "doxygen"
Alexander Afanasyev7a696fb2012-03-01 17:17:22 -0800157
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800158def doxygen (bld):
Alexander Afanasyev34ebcb72012-03-08 15:54:55 -0800159 if not bld.env.DOXYGEN:
160 bld.fatal ("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
Alexander Afanasyev182fdc22012-03-05 18:06:52 -0800161 bld (features="doxygen",
162 doxyfile='doc/doxygen.conf',
163 output_dir = 'doc')