blob: 210b79c41dbda72d01be9779cc1286091824a0e0 [file] [log] [blame]
Ilya Moiseenko1762af72011-07-18 16:43:10 -07001## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07003import os
Alexander Afanasyev152660b2013-01-08 09:33:05 -08004from waflib import Logs, Utils, Options, TaskGen, Task
Alexander Afanasyev9de011f2011-11-11 00:55:05 -08005from waflib.Errors import WafError
6
Alexander Afanasyeva65ab322012-10-23 21:43:39 -07007import wutils
8
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -07009REQUIRED_BOOST_LIBS = ['graph', 'thread', 'unit_test_framework',
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080010 'system', 'random', 'date_time', 'iostreams', 'regex',
11 'program_options', 'chrono', 'filesystem']
Alexander Afanasyev3b936292011-09-20 08:45:36 -070012
Alexander Afanasyev152660b2013-01-08 09:33:05 -080013def required_boost_libs(conf):
14 conf.env.REQUIRED_BOOST_LIBS += REQUIRED_BOOST_LIBS
15
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000016def options(opt):
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070017 opt.load(['version'], tooldir=['%s/.waf-tools' % opt.path.abspath()])
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080018 opt.load(['doxygen', 'sphinx_build', 'type_traits', 'compiler-features', 'cryptopp', 'sqlite3', 'openssl'],
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070019 tooldir=['%s/ndn-cxx/.waf-tools' % opt.path.abspath()])
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000020
Alexander Afanasyev152660b2013-01-08 09:33:05 -080021def configure(conf):
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080022 conf.load(['doxygen', 'sphinx_build', 'type_traits', 'compiler-features', 'version', 'cryptopp', 'sqlite3', 'openssl'])
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000023
24 conf.env['ENABLE_NDNSIM']=False
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080025
Alexander Afanasyevce308b62015-01-20 18:17:28 -080026 if not os.environ.has_key('PKG_CONFIG_PATH'):
27 os.environ['PKG_CONFIG_PATH'] = ':'.join([
28 '/usr/local/lib/pkgconfig',
Alexander Afanasyevfee51a02015-03-31 23:18:56 -070029 '/usr/local/lib64/pkgconfig',
30 '/usr/local/lib32/pkgconfig',
Alexander Afanasyevce308b62015-01-20 18:17:28 -080031 '/opt/local/lib/pkgconfig'])
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070032
33 conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD', mandatory=False)
34 conf.check_sqlite3(mandatory=True)
35 conf.check_cryptopp(mandatory=True, use='PTHREAD')
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080036 conf.check_openssl(mandatory=True, use='OPENSSL', atleast_version=0x10001000)
Alexander Afanasyev60c04622014-12-29 20:43:22 -080037
Alexander Afanasyev3b936292011-09-20 08:45:36 -070038 if not conf.env['LIB_BOOST']:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080039 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070040 "Required boost libraries not found")
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080041 Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.54.0")
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070042 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070043 return
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080044 else:
Alexander Afanasyev152660b2013-01-08 09:33:05 -080045 present_boost_libs = []
46 for boost_lib_name in conf.env['LIB_BOOST']:
47 if boost_lib_name.startswith("boost_"):
48 boost_lib_name = boost_lib_name[6:]
49 if boost_lib_name.endswith("-mt"):
50 boost_lib_name = boost_lib_name[:-3]
Alexander Afanasyevcd38c842013-05-05 00:24:41 -070051 present_boost_libs.append(boost_lib_name)
Alexander Afanasyev152660b2013-01-08 09:33:05 -080052
53 missing_boost_libs = [lib for lib in REQUIRED_BOOST_LIBS if lib not in present_boost_libs]
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070054
Alexander Afanasyev152660b2013-01-08 09:33:05 -080055 if missing_boost_libs != []:
56 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
57 "ndnSIM requires boost libraries: %s" % ' '.join(missing_boost_libs))
58 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
59
60 Logs.error ("ndnSIM will not be build as it requires boost libraries: %s" % ' '.join(missing_boost_libs))
61 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
62 return
Alexander Afanasyevb4921ec2013-08-07 17:45:01 -070063
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080064 boost_version = conf.env.BOOST_VERSION.split('_')
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080065 if int(boost_version[0]) < 1 or int(boost_version[1]) < 54:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080066 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080067 "ndnSIM requires at least boost version 1.54")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080068 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
69
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080070 Logs.error ("ndnSIM will not be build as it requires boost libraries of version at least 1.54")
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080071 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
72 return
Alexander Afanasyevac46d452012-05-31 15:33:21 -070073
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080074 conf.env['ENABLE_NDNSIM']=True;
75 conf.env['MODULES_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070076
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080077 conf.report_optional_feature("ndnSIM", "ndnSIM", True, "")
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070078
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070079 conf.write_config_header('../../ns3/ndnSIM/ndn-cxx/ndn-cxx-config.hpp', define_prefix='NDN_CXX_', remove=False)
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080080 conf.write_config_header('../../ns3/ndnSIM/NFD/core/config.hpp', remove=False)
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -070081
Ilya Moiseenko1762af72011-07-18 16:43:10 -070082def build(bld):
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -070083 (base, build, split) = bld.getVersion('NFD')
84 bld(features="subst",
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070085 name="version-NFD",
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -080086 source='NFD/core/version.hpp.in', target='../../ns3/ndnSIM/NFD/core/version.hpp',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070087 install_path=None,
88 VERSION_STRING=base,
89 VERSION_BUILD="%s-ndnSIM" % build,
90 VERSION=int(split[0]) * 1000000 + int(split[1]) * 1000 + int(split[2]),
91 VERSION_MAJOR=split[0], VERSION_MINOR=split[1], VERSION_PATCH=split[2])
92
93 (base, build, split) = bld.getVersion('ndn-cxx')
94 bld(features="subst",
95 name="version-ndn-cxx",
96 source='ndn-cxx/src/version.hpp.in', target='../../ns3/ndnSIM/ndn-cxx/version.hpp',
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -070097 install_path=None,
98 VERSION_STRING=base,
99 VERSION_BUILD="%s-ndnSIM" % build,
100 VERSION=int(split[0]) * 1000000 + int(split[1]) * 1000 + int(split[2]),
101 VERSION_MAJOR=split[0], VERSION_MINOR=split[1], VERSION_PATCH=split[2])
102
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800103 deps = ['core', 'network', 'point-to-point', 'topology-read', 'mobility', 'internet']
Alexander Afanasyev0d584e32013-08-13 10:41:42 -0700104 if 'ns3-visualizer' in bld.env['NS3_ENABLED_MODULES']:
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800105 deps.append('visualizer')
Alexander Afanasyev3bea3702011-11-16 10:27:18 -0800106
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800107 if bld.env.ENABLE_EXAMPLES:
Alexander Afanasyev15db7722015-01-19 17:27:26 -0800108 deps += ['point-to-point-layout', 'csma', 'applications', 'wifi']
Alexander Afanasyev4a3b2be2012-06-29 14:29:13 -0700109
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700110 ndnCxxSrc = bld.path.ant_glob('ndn-cxx/src/**/*.cpp',
111 excl=['ndn-cxx/src/**/*-osx.cpp',
112 'ndn-cxx/src/util/dummy-client-face.cpp'])
Alexander Afanasyev404c0792011-08-09 17:09:59 -0700113
Spyridon Mastorakis8fde22b2015-08-19 23:12:44 -0700114 nfdSrc = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in ['NFD/core', 'NFD/daemon', 'NFD/rib']],
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700115 excl=['NFD/daemon/main.cpp',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700116 'NFD/daemon/nfd.cpp',
117 'NFD/daemon/face/ethernet*',
118 'NFD/daemon/face/multicast-udp*',
119 'NFD/daemon/face/tcp*',
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700120 'NFD/daemon/face/*udp*',
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700121 'NFD/daemon/face/unix-stream*',
Spyridon Mastorakis8fde22b2015-08-19 23:12:44 -0700122 'NFD/daemon/face/websocket*',
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800123 'NFD/rib/service.cpp'])
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700124
125 module = bld.create_ns3_module('ndnSIM', deps)
126 module.module = 'ndnSIM'
127 module.features += ' ns3fullmoduleheaders ndncxxheaders'
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800128 module.use += ['version-ndn-cxx', 'version-NFD', 'BOOST', 'CRYPTOPP', 'SQLITE3', 'RT', 'PTHREAD', 'OPENSSL']
Spyridon Mastorakis8fde22b2015-08-19 23:12:44 -0700129 module.includes = ['../..', '../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM', '../../ns3/ndnSIM/ndn-cxx']
130 module.export_includes = ['../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM']
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700131
132 headers = bld(features='ns3header')
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700133 headers.module = 'ndnSIM'
Alexander Afanasyev60c04622014-12-29 20:43:22 -0800134 headers.source = ["ndn-all.hpp"]
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700135
Alexander Afanasyev1bfce322012-11-23 21:38:02 -0800136 if not bld.env['ENABLE_NDNSIM']:
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -0700137 bld.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700138 return
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800139
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800140 module_dirs = ['apps', 'helper', 'model', 'utils', 'bindings']
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700141 module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs],
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700142 excl=[
Alexander Afanasyev325c2532016-09-08 15:38:53 -0700143 'model/ip-faces/*']) + ndnCxxSrc + nfdSrc
Alexander Afanasyev2a5df202011-08-15 22:39:05 -0700144
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800145 module_dirs = ['NFD/core', 'NFD/daemon', 'NFD/rib', 'apps', 'helper', 'model', 'utils', 'bindings']
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700146 module.full_headers = bld.path.ant_glob(['%s/**/*.hpp' % dir for dir in module_dirs])
147 module.full_headers += bld.path.ant_glob('NFD/common.hpp')
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700148
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700149 module.ndncxx_headers = bld.path.ant_glob(['ndn-cxx/src/**/*.hpp'],
150 excl=['src/**/*-osx.hpp', 'src/detail/**/*'])
Alexander Afanasyev50ea1a32016-09-08 15:44:08 -0700151 if bld.env.ENABLE_EXAMPLES:
152 bld.recurse('examples')
Lucas64b85362012-01-30 16:28:37 -0800153
Spyridon Mastorakisb4bd4b72015-01-05 17:41:12 -0800154 if bld.env.ENABLE_TESTS:
155 bld.recurse('tests')
156
Alexander Afanasyevc018a562016-09-08 16:27:31 -0700157 bld.ns3_python_bindings()
Alexander Afanasyev59314802012-11-26 14:56:04 -0800158
Alexander Afanasyev59314802012-11-26 14:56:04 -0800159@TaskGen.feature('ns3fullmoduleheaders')
160@TaskGen.after_method('process_rule')
161def apply_ns3fullmoduleheaders(self):
162 # ## get all of the ns3 headers
Alexander Afanasyev1a62e612013-05-02 16:50:48 -0700163 ns3_dir_node = self.bld.path.find_or_declare("ns3")
Alexander Afanasyev59314802012-11-26 14:56:04 -0800164
165 mode = getattr(self, "mode", "install")
166
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700167 for src_node in set(self.full_headers):
Alexander Afanasyev59314802012-11-26 14:56:04 -0800168 dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src')))
169 assert dst_node is not None
170
171 relpath = src_node.parent.path_from(self.bld.path.find_dir('src'))
172
173 task = self.create_task('ns3header')
174 task.mode = getattr(self, 'mode', 'install')
175 if task.mode == 'install':
Alexander Afanasyev957a84a2013-01-23 10:21:06 -0800176 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
Alexander Afanasyev59314802012-11-26 14:56:04 -0800177 [src_node])
178 task.set_inputs([src_node])
179 task.set_outputs([dst_node])
180 else:
181 task.header_to_remove = dst_node
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -0700182
183@TaskGen.feature('ndncxxheaders')
184@TaskGen.after_method('process_rule')
185def apply_ndnsim_moduleheaders(self):
186 # ## get all of the ns3 headers
187 ndncxx_dir_node = self.bld.path.find_or_declare("ns3/ndnSIM/ndn-cxx")
188
189 mode = getattr(self, "mode", "install")
190
191 for src_node in set(self.ndncxx_headers):
192 dst_node = ndncxx_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/src')))
193 assert dst_node is not None
194
195 relpath = src_node.parent.path_from(self.bld.path.find_dir('src/ndnSIM/ndn-cxx/src'))
196
197 task = self.create_task('ns3header')
198 task.mode = getattr(self, 'mode', 'install')
199 if task.mode == 'install':
200 self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM/ndn-cxx/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
201 [src_node])
202 task.set_inputs([src_node])
203 task.set_outputs([dst_node])
204 else:
205 task.header_to_remove = dst_node