blob: 9b61d52682c4d54d5c3c9654ab7da55711930eed [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
4import Logs
5import Utils
Alexander Afanasyev2a5df202011-08-15 22:39:05 -07006import Options
7
Alexander Afanasyev9de011f2011-11-11 00:55:05 -08008from waflib.Errors import WafError
9
Alexander Afanasyeva65ab322012-10-23 21:43:39 -070010import wutils
11
Alexander Afanasyev3b936292011-09-20 08:45:36 -070012def options(opt):
13 opt.tool_options('boost', tooldir=["waf-tools"])
Alexander Afanasyevac46d452012-05-31 15:33:21 -070014 opt.add_option('--enable-ndn-plugins',
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080015 help=("Enable NDN plugins (may require patching). topology plugin enabled by default"),
Alexander Afanasyevac46d452012-05-31 15:33:21 -070016 dest='enable_ndn_plugins')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070017
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080018 opt.add_option('--disable-ndn-plugins',
19 help=("Enable NDN plugins (may require patching). topology plugin enabled by default"),
20 dest='disable_ndn_plugins')
21
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070022def configure(conf):
Alexander Afanasyev3b936292011-09-20 08:45:36 -070023 try:
24 conf.check_tool('boost')
25 conf.check_boost(lib = 'iostreams')
26 except WafError:
27 conf.env['LIB_BOOST'] = []
28
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080029 conf.env['ENABLE_NDNSIM']=False;
30
Alexander Afanasyev3b936292011-09-20 08:45:36 -070031 if not conf.env['LIB_BOOST']:
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080032 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070033 "Required boost libraries not found")
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070034 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070035 return
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080036 else:
37 boost_version = conf.env.BOOST_VERSION.split('_')
38 if int(boost_version[0]) < 1 or int(boost_version[1]) < 48:
39 conf.report_optional_feature("ndnSIM", "ndnSIM", False,
40 "ndnSIM requires at least boost version 1.48")
41 conf.env['MODULES_NOT_BUILT'].append('ndnSIM')
42
43 Logs.error ("ndnSIM requires at least boost version 1.48")
44 Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)")
45 return
Alexander Afanasyevac46d452012-05-31 15:33:21 -070046
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080047 conf.env['NDN_plugins'] = ['topology']
Alexander Afanasyevac46d452012-05-31 15:33:21 -070048 if Options.options.enable_ndn_plugins:
Alexander Afanasyeve8dab502012-11-21 16:17:51 -080049 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] + Options.options.enable_ndn_plugins.split(',')
50
51 if Options.options.disable_ndn_plugins:
52 conf.env['NDN_plugins'] = conf.env['NDN_plugins'] - Options.options.disable_ndn_plugins.split(',')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070053
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080054 conf.env['ENABLE_NDNSIM']=True;
55 conf.env['MODULES_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070056
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080057 conf.report_optional_feature("ndnSIM", "ndnSIM", True, "")
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070058
Ilya Moiseenko1762af72011-07-18 16:43:10 -070059def build(bld):
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070060 deps = ['core', 'network', 'point-to-point']
61 deps.append ('internet') # Until RttEstimator is moved to network module
Alexander Afanasyev3bea3702011-11-16 10:27:18 -080062 if bld.env['ENABLE_PYTHON_BINDINGS']:
63 deps.append ('visualizer')
64
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070065 if 'topology' in bld.env['NDN_plugins']:
66 deps.append ('topology-read')
67
Alexander Afanasyev4a3b2be2012-06-29 14:29:13 -070068 if 'mobility' in bld.env['NDN_plugins']:
69 deps.append ('mobility')
70
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070071 module = bld.create_ns3_module ('ndnSIM', deps)
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070072 module.uselib = 'BOOST BOOST_IOSTREAMS'
Alexander Afanasyev404c0792011-08-09 17:09:59 -070073
Alexander Afanasyev3b936292011-09-20 08:45:36 -070074 headers = bld.new_task_gen(features=['ns3header'])
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070075 headers.module = 'ndnSIM'
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070076
Alexander Afanasyev1bfce322012-11-23 21:38:02 -080077 if not bld.env['ENABLE_NDNSIM']:
Alexander Afanasyev57bcbc32012-06-01 01:46:24 -070078 bld.env['MODULES_NOT_BUILT'].append('ndnSIM')
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070079 return
80
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070081 module.source = bld.path.ant_glob(['model/**/*.cc',
82 'apps/*.cc',
Alexander Afanasyev1a2df6a2012-08-17 13:21:51 -070083 'utils/**/*.cc',
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070084 'helper/**/*.cc',
85 ])
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070086
Alexander Afanasyev07827182011-12-13 01:07:32 -080087 headers.source = [
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070088 "helper/ndn-stack-helper.h",
89 "helper/ndn-app-helper.h",
90 "helper/ndn-header-helper.h",
91 "helper/ndn-face-container.h",
92 "helper/ndn-global-routing-helper.h",
Ilya Moiseenko1762af72011-07-18 16:43:10 -070093
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070094 "apps/ndn-app.h",
Alexander Afanasyev07827182011-12-13 01:07:32 -080095
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070096 "model/ndn-l3-protocol.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070097 "model/ndn-face.h",
98 "model/ndn-app-face.h",
99 "model/ndn-net-device-face.h",
Alexander Afanasyevbd9c18e2012-11-19 15:23:41 -0800100 "model/ndn-interest.h",
101 "model/ndn-content-object.h",
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700102 "model/ndn-name-components.h",
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700103
104 "model/cs/ndn-content-store.h",
105
106 "model/fib/ndn-fib.h",
107 "model/fib/ndn-fib-entry.h",
108
109 "model/pit/ndn-pit.h",
110 "model/pit/ndn-pit-entry.h",
111 "model/pit/ndn-pit-entry-incoming-face.h",
112 "model/pit/ndn-pit-entry-outgoing-face.h",
113
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700114 "model/fw/ndn-forwarding-strategy.h",
Alexander Afanasyeved449cc2012-08-21 11:10:33 -0700115 "model/fw/ndn-fw-tag.h",
Alexander Afanasyev4975f732011-12-20 17:52:19 -0800116
Alexander Afanasyevf5c07742012-10-31 13:13:05 -0700117 # "utils/batches.h",
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700118 "utils/ndn-limits.h",
Alexander Afanasyevc1e33eb2012-05-31 12:13:17 -0700119 # "utils/weights-path-stretch-tag.h",
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700120
Alexander Afanasyev07827182011-12-13 01:07:32 -0800121 ]
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700122
Alexander Afanasyevac46d452012-05-31 15:33:21 -0700123 if 'topology' in bld.env['NDN_plugins']:
124 headers.source.extend ([
125 "plugins/topology/rocketfuel-weights-reader.h",
126 "plugins/topology/annotated-topology-reader.h",
127 ])
128 module.source.extend (bld.path.ant_glob(['plugins/topology/*.cc']))
129
130 if 'mobility' in bld.env['NDN_plugins']:
131 headers.source.extend ([
132 "plugins/mobility/spring-mobility-model.h",
133 "plugins/mobility/spring-mobility-helper.h",
134 ])
135 module.source.extend (bld.path.ant_glob(['plugins/mobility/*.cc']))
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700136
137 ndnSIM_headers = [p.path_from(bld.path) for p in bld.path.ant_glob([
138 'utils/**/*.h',
139 'model/**/*.h',
140 'apps/**/*.h',
141 'helper/**/*.h',
142 ])]
143 bld.install_files('${INCLUDEDIR}/%s%s/ns3/ndnSIM' % (wutils.APPNAME, wutils.VERSION), ndnSIM_headers, relative_trick=True)
144 # bld.install_files('$PREFIX/include', ndnSIM_headers)
Alexander Afanasyevac46d452012-05-31 15:33:21 -0700145
Alexander Afanasyev5662b362012-07-11 13:34:21 -0700146 tests = bld.create_ns3_module_test_library('ndnSIM')
Alexander Afanasyeva65ab322012-10-23 21:43:39 -0700147 tests.source = bld.path.ant_glob('test/*.cc')
Alexander Afanasyev3b936292011-09-20 08:45:36 -0700148
Alexander Afanasyevf04d4512012-02-14 18:42:47 -0800149 if bld.env.ENABLE_EXAMPLES:
150 bld.add_subdirs('examples')
Lucas64b85362012-01-30 16:28:37 -0800151
Alexander Afanasyev07827182011-12-13 01:07:32 -0800152 bld.ns3_python_bindings()