src/internet-stack/wscript
changeset 4065 f18c257dd25e
parent 4064 10222f483860
parent 4033 6abf5a0f12d7
child 4074 5780617d9521
equal deleted inserted replaced
4064:10222f483860 4065:f18c257dd25e
    17 NSC_DIR = "nsc"
    17 NSC_DIR = "nsc"
    18 
    18 
    19 
    19 
    20 def set_options(opt):
    20 def set_options(opt):
    21     opt.add_option('--enable-nsc',
    21     opt.add_option('--enable-nsc',
    22                    help=('Enable Network Simulation Cradle to allow the use real-world network stacks'),
    22                    help=('[deprecated option] Enable Network Simulation Cradle to allow the use real-world network stacks'),
    23                    action="store_true", default=False,
    23                    action="store_true", default=False,
    24                    dest='enable_nsc')
    24                    dest='enable_nsc')
       
    25     opt.add_option('--with-nsc',
       
    26                    help=('Use Network Simulation Cradle, given by the indicated path,'
       
    27                          ' to allow the use of real-world network stacks'),
       
    28                    default='', dest='with_nsc')
    25 
    29 
    26 
    30 
    27 def nsc_fetch():
    31 def nsc_fetch():
    28     def nsc_clone():
    32     def nsc_clone():
    29         print "Retrieving nsc from " + NSC_REPO
    33         print "Retrieving nsc from " + NSC_REPO
    64         import flex
    68         import flex
    65         import bison
    69         import bison
    66         conf.check_tool('flex bison')
    70         conf.check_tool('flex bison')
    67         conf.check(lib='fl', mandatory=True)
    71         conf.check(lib='fl', mandatory=True)
    68 
    72 
    69     if not Options.options.enable_nsc:
    73     if not (Options.options.enable_nsc or Options.options.with_nsc):
    70         conf.report_optional_feature("nsc", "Network Simulation Cradle", False,
    74         conf.report_optional_feature("nsc", "Network Simulation Cradle", False,
    71                                      "--enable-nsc configure option not given")
    75                                      "--with/enable-nsc configure option not given")
    72 	return
    76 	return
    73 
    77 
    74     check_nsc_buildutils()
    78     check_nsc_buildutils()
       
    79     if Options.options.enable_nsc:
       
    80         Logs.warn("--enable-nsc is a deprecated option; use --with-nsc instead")
       
    81         conf.env['WITH_NSC'] = 'nsc'
       
    82 
       
    83     if Options.options.with_nsc:
       
    84         if not os.path.isdir(Options.options.with_nsc):
       
    85             raise Utils.WafError("--with-nsc nsc path %r does not exist" % Options.options.with_nsc)
       
    86         conf.env['WITH_NSC'] = Options.options.with_nsc
    75 
    87 
    76     arch = os.uname()[4]
    88     arch = os.uname()[4]
    77     ok = False
    89     ok = False
    78     if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
    90     if arch == 'x86_64' or arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
    79         conf.env['NSC_ENABLED'] = 'yes'
    91         conf.env['NSC_ENABLED'] = 'yes'
    80         conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
    92         conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
    81         conf.env['ENABLE_NSC'] = conf.check(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
    93         conf.check(mandatory=True, lib='dl', define_name='HAVE_DL', uselib='DL')
    82         ok = True
    94         ok = True
    83     conf.check_message('NSC supported architecture', arch, ok)
    95     conf.check_message('NSC supported architecture', arch, ok)
    84     conf.report_optional_feature("nsc", "Network Simulation Cradle", ok,
    96     conf.report_optional_feature("nsc", "Network Simulation Cradle", ok,
    85                                  "architecture %r not supported" % arch)
    97                                  "architecture %r not supported" % arch)
    86     nsc_fetch()
    98     if not Options.options.with_nsc:
       
    99         nsc_fetch()
    87 
   100 
    88 
   101 
    89 
   102 
    90 class NscBuildTask(Task.TaskBase):
   103 class NscBuildTask(Task.TaskBase):
    91     """task that builds nsc
   104     """task that builds nsc
    92     """
   105     """
    93     after = 'link' # build after the rest of ns-3
   106     after = 'cc_link cxx_link' # build after the rest of ns-3
    94     def __init__(self, builddir):
   107     def __init__(self, builddir, nsc_dir, env):
       
   108         super(NscBuildTask, self).__init__()
    95         self.builddir = builddir
   109         self.builddir = builddir
    96         super(NscBuildTask, self).__init__()
   110         self.env = env
    97         self.display = 'build-nsc\n'
   111         self.nsc_dir = nsc_dir
       
   112 
       
   113     def display(self):
       
   114         return 'build-nsc\n'
    98 
   115 
    99     def run(self):
   116     def run(self):
   100         # XXX: Detect gcc major version(s) available to build supported stacks
   117         # XXX: Detect gcc major version(s) available to build supported stacks
   101         builddir = self.builddir
   118         builddir = self.builddir
   102         kernels = [['linux-2.6.18', 'linux2.6.18'],
   119         kernels = [['linux-2.6.18', 'linux2.6.18'],
   103                    ['linux-2.6.26', 'linux2.6.26']]
   120                    ['linux-2.6.26', 'linux2.6.26']]
   104         for dir, name in kernels:
   121         for dir, name in kernels:
   105             soname = 'lib' + name + '.so'
   122             soname = 'lib' + name + '.so'
   106             if not os.path.exists(os.path.join("..", NSC_DIR, dir, soname)):
   123             if not os.path.exists(os.path.join("..", self.nsc_dir, dir, soname)):
   107                 if os.system('cd ../%s && python scons.py %s' % (NSC_DIR, dir)) != 0:
   124                 if os.system('cd ../%s && python scons.py %s' % (self.nsc_dir, dir)) != 0:
   108                     raise Utils.WafError("Building NSC stack failed")
   125                     raise Utils.WafError("Building NSC stack failed")
   109 
   126 
   110             if not os.path.exists(builddir + '/' + soname):
   127             if not os.path.exists(builddir + '/' + soname):
   111                 try:
   128                 try:
   112                     os.symlink('../../' + NSC_DIR + '/' + dir + '/' + soname, builddir +  '/' + soname)
   129                     os.symlink('../../' + self.nsc_dir + '/' + dir + '/' + soname, builddir +  '/' + soname)
   113                 except:
   130                 except:
   114                     raise Utils.WafError("Error linking " + builddir + '/' + soname)
   131                     raise Utils.WafError("Error linking " + builddir + '/' + soname)
   115 
   132 
   116 
   133 
   117 def build(bld):
   134 def build(bld):
   161         'ipv4-static-routing.h',
   178         'ipv4-static-routing.h',
   162         'ipv4-global-routing.h',
   179         'ipv4-global-routing.h',
   163         'icmpv4.h',
   180         'icmpv4.h',
   164         ]
   181         ]
   165 
   182 
   166     if bld.env['NSC_ENABLED']:        
   183     if bld.env['WITH_NSC']:        
   167         obj.source.append ('nsc-tcp-socket-impl.cc')
   184         obj.source.append ('nsc-tcp-socket-impl.cc')
   168         obj.source.append ('nsc-tcp-l4-protocol.cc')
   185         obj.source.append ('nsc-tcp-l4-protocol.cc')
   169         obj.source.append ('nsc-tcp-socket-factory-impl.cc')
   186         obj.source.append ('nsc-tcp-socket-factory-impl.cc')
   170         obj.source.append ('nsc-sysctl.cc')
   187         obj.source.append ('nsc-sysctl.cc')
   171         obj.uselib = 'DL'
   188         obj.uselib = 'DL'
   172         builddir = os.path.abspath(os.path.join(bld.env['NS3_BUILDDIR'], bld.env ().variant()))
   189         builddir = os.path.abspath(os.path.join(bld.env['NS3_BUILDDIR'], bld.env.variant()))
   173         NscBuildTask(builddir)
   190         NscBuildTask(builddir, bld.env['WITH_NSC'], bld.env)